Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
Need help passing arrays by reference pls.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Ben Morrow, post: 4755312"] <snip benchmark> A tool I like for answering this sort of question is B::Graph, which produces a graph of the optree. It seems that print "a", "b"; becomes nextstate -> pushmark -> const -> const -> print (nextstate starts a new statement. pushmark makes a mark in the Perl stack to show where the arguments for the print begin. The consts push items onto the stack, the print takes them off down to the mark and prints them) whereas print "a" . "b"; becomes nextstate -> pushmark -> const -> print ie. perl will perform the concatenation at compile time, and thus it must be more efficient. However, print "a", $x; becomes nextstate -> pushmark -> const -> padsv -> print as before (padsv gets the value of the variable and pushes it onto the stack) whereas print "a" . $x; becomes nextstate -> pushmark -> const -> padsv -> concat -> print ie. the concatenation is done as a separate step before the print, so it may well be slower (this depends on whether printing several items as opposed to one is slower or faster than concatenating them). Certainly it is not true that they are the same: I suspect Walter was thinking of print "a$x"; which *is* converted into print "a" . $x; internally. Ben [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Need help passing arrays by reference pls.
Top