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

Re: Match Numeric Range

by dbuckhal (Chaplain)
on Aug 18, 2015 at 05:31 UTC ( [id://1138954]=note: print w/replies, xml ) Need Help??


in reply to Match Numeric Range

Flip-flop, maybe?
perl -le '@full = ( 0..100 ); for ( @full ) { print STDOUT "$_: LIGHTS ON" if /20/ .. /30/; print STDOUT "$_: LIGHTS OFF" if /60/ .. /70/; } ' __output__ 20: LIGHTS ON 21: LIGHTS ON 22: LIGHTS ON 23: LIGHTS ON 24: LIGHTS ON 25: LIGHTS ON 26: LIGHTS ON 27: LIGHTS ON 28: LIGHTS ON 29: LIGHTS ON 30: LIGHTS ON 60: LIGHTS OFF 61: LIGHTS OFF 62: LIGHTS OFF 63: LIGHTS OFF 64: LIGHTS OFF 65: LIGHTS OFF 66: LIGHTS OFF 67: LIGHTS OFF 68: LIGHTS OFF 69: LIGHTS OFF 70: LIGHTS OFF
Though I do not know the proper syntax with variable assignment, so cannot turn the durn lights off! So, it half works....
perl -le '@full = ( 0..20 ); for $ea ( @full ) { print STDOUT "$ea: LIGHTS ON" if $ea =~ /6/ .. /10/; print STDOUT "$ea: LIGHTS OFF" if $ea =~ /15/ .. /20/; } ' __output__ 6: LIGHTS ON 7: LIGHTS ON 8: LIGHTS ON 9: LIGHTS ON 10: LIGHTS ON 11: LIGHTS ON 12: LIGHTS ON 13: LIGHTS ON 14: LIGHTS ON 15: LIGHTS ON 15: LIGHTS OFF 16: LIGHTS ON 16: LIGHTS OFF 17: LIGHTS ON 17: LIGHTS OFF 18: LIGHTS ON 18: LIGHTS OFF 19: LIGHTS ON 19: LIGHTS OFF 20: LIGHTS ON 20: LIGHTS OFF
Hope it helps!

Replies are listed 'Best First'.
Re^2: Match Numeric Range
by PilotinControl (Pilgrim) on Aug 18, 2015 at 13:56 UTC

    Hello dbuckhal...I added the correct syntax and in theory it does work...when applied to my situation it does not. Thanks for the input!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-18 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found