Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

search for vertical bars

by Anonymous Monk
on Jul 17, 2002 at 21:55 UTC ( #182598=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

if(param("des") || param("title") =~ m[\|]) { &inerror("You cant include |'s in your text"); }
This doesnt work, all I want do is check to see if they contain vertical bars

Replies are listed 'Best First'.
Re: search for vertical bars
by DamnDirtyApe (Curate) on Jul 17, 2002 at 22:03 UTC

    I think what you mean to say is:

    if(param("des") =~ m[\|] || param("title") =~ m[\|]) { &inerror("You cant include |'s in your text"); }

    _______________
    D a m n D i r t y A p e
    Home Node | Email
Re: search for vertical bars (Russ was bored)
by Russ (Deacon) on Jul 18, 2002 at 00:04 UTC
    Just because I cringe at duplicated code (and my duplicate threshold is very low ;-)

    Nothing at all wrong with DamnDirtyApe's answer... Like the title says, I was bored and just had to post.

    if (grep {/\|/} (param('des'), param('title')){ # at least one of them matched }

    Russ
    Brainbench 'Most Valuable Professional' for Perl

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://182598]
Approved by VSarkiss
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2022-06-26 05:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (83 votes). Check out past polls.

    Notices?