Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: process array with while loop

by shawnhcorey (Friar)
on Nov 10, 2006 at 15:39 UTC ( [id://583348]=note: print w/replies, xml ) Need Help??


in reply to Re^2: process array with while loop
in thread process array with while loop

Except that print is not a void context. Therefore the map will create a list.
#!/usr/bin/perl use strict; use warnings; my $a = ( print "Hello world\n" ); print "The answer is $a\n"; __END__
See `perldoc -f print` for details.

Replies are listed 'Best First'.
Re^4: process array with while loop
by davorg (Chancellor) on Nov 14, 2006 at 14:04 UTC
    Except that print is not a void context.

    I think you might be misunderstanding. blahblah wasn't talking about the call to print. He was talking about the call to map ("map in a void context"). And the call to map is in a void context - its return value doesn't go anywhere. But as he also pointed out, that's no longer a problem. Or, at least, it's not a problem from a technical point of view. I'd still argue that it's not the clearest way to write the code.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-19 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found