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

Re: $_ not optional with lexical prints

Thread Previous | Thread Next
From:
Spider Boardman
Date:
March 20, 2003 10:08
Subject:
Re: $_ not optional with lexical prints
Message ID:
200303201807.NAA488355@leggy.zk3.dec.com
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.

	--s.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About