develooper Front page | perl.perl5.porters | Postings from March 2003

Re: $_ not optional with lexical prints

Thread Previous | Thread Next
Spider Boardman
March 20, 2003 10:08
Re: $_ not optional with lexical prints
Message ID:
On Thu, 20 Mar 2003 18:45:25 +0100, "H.Merijn Brand" wrote (in part):

hmb> I've not digged in the sources, but is it not the case that
hmb> eventually an internal call is made to the perl representative of
hmb> "print" with just a bunch of arguments, and that *this* function has
hmb> to look what is passed?

Not really.  The parser adds the missing $_ when it thinks that what you
meant, and sets the OPf_STACKED flag when a non-default filehandle is
present.  The pp_print routine only needs to check OPf_STACKED vs. the
default output handle.

Check with -DDEBUGGING perl the output from these:

	perl -Dx -c -e 'print'
	perl -Dx -c -e 'print $a'
	perl -Dx -c -e 'print FOO'
	perl -Dx -c -e 'print FOO $a'

The first and third cases will have an 'extra' $main::_ added, and the
latter two will have ",STACKED" in the dump of the print op.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About