Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Order of printf statements vs order of actual lines printed out

by davido (Archbishop)
on Apr 09, 2013 at 05:20 UTC ( #1027645=note: print w/ replies, xml ) Need Help??


in reply to Order of printf statements vs order of actual lines printed out

It's because of the error right here:

printf "\nabove first set of dashes#: [" . #@foo . "]\n"; # The error is -------------------here------^^

So, what's happening? By typing #@ when you meant to type $# you initiated a comment. So "@foo . "\n"; was no longer code, but rather, a comment. That made the line in question look like this:

printf "\nabove first set of dashes#: [" . printf "first set of dashes------------\n";

Notice how you're using the concatenation operator, "." to append the output from "printf  "first set of dashes------------\n";" to the string "\nabove first set of dashes#:  [". Before that concatenation can occur, that second printf has to be evaluated to obtain its return value (which is "1"). And in so doing, its side effect (in the functional sense) is taking place: It's printing the "first set of dashes....." line.


Dave


Comment on Re: Order of printf statements vs order of actual lines printed out
Select or Download Code

Log In?
Username:
Password:

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

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

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls