Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Logical Not and arguments to grep

by Marshall (Canon)
on Apr 02, 2012 at 01:02 UTC ( [id://962947]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Logical Not and arguments to grep
in thread Logical Not and arguments to grep

I also prefer to use the block form of map and grep.

The comma operator is useful in other ways..see the command loop I coded at Re: Storing 10 numbers in array. In the statement,

while ( (print "$prompt: "), $number = <STDIN> ) {...}
The comma operator allows this to be a single statement.
You can't put two statements like:
print "$prompt"; $number = <STDIN>;
into the while() conditional. But this statement which uses the comma operator is ok. The "truth or falseness" of the statement is decided by the last clause (the input of the data - not the return value of the print which will be a "1"). Note the paren's are required.

By doing it this way, a re-prompt happens automatically at every loop iteration without having to code the prompting statement within the loop (and having a standalone initial prompting statement before the loop to get things started).

Log In?
Username:
Password:

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

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

    No recent polls found