Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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 }

    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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2023-11-29 19:24 GMT
Find Nodes?
    Voting Booth?

    No recent polls found