Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: grep flip flop (range operator)

by Anonymous Monk
on Sep 13, 2012 at 07:02 UTC ( #993383=note: print w/ replies, xml ) Need Help??


in reply to Re: grep flip flop (range operator)
in thread grep flip flop (range operator)

Bingo. Thanks.

That "Range Operators" page I have now read in my console via perldoc -f ..

It dawned on me after posting that the first condition is never true and I came up with

$ perl -le " print for grep { my $what = scalar($Q++==0 ..($_ eq q{Q} +)); warn $what; $what } qw{ a b c Q r s }; " 1 at -e line 1. 2 at -e line 1. 3 at -e line 1. 4E0 at -e line 1. Warning: something's wrong at -e line 1. Warning: something's wrong at -e line 1. a b c Q


Comment on Re^2: grep flip flop (range operator)
Download Code
Re^3: grep flip flop (range operator)
by frozenwithjoy (Curate) on Sep 13, 2012 at 07:34 UTC
    To make things a bit more readable, you could use the match-once operator like this:
    perl -le " print for grep ?? .. /Q/, @ARGV " a b c Q r s ___ a b c Q

      Uh-oh

      $ perldoc -f ?? No documentation for perl function '??' found

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2014-08-29 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls