Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: grep {CONSTANT} @list

by tobyink (Abbot)
on Nov 21, 2012 at 20:08 UTC ( #1004998=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use constant REGEXP => qr(a);
    print grep { REGEXP } qw(a b c);
    
  2. or download this
    my @tmp;
    foreach (qw(a b c)) {
       push @tmp, $_ if qr(a);
    }
    print @tmp;
    
  3. or download this
    print grep { $_ =~ REGEXP } @list;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004998]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2014-07-10 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (209 votes), past polls