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

Re: $_ not optional with lexical prints

Thread Previous
H.Merijn Brand
March 20, 2003 10:12
Re: $_ not optional with lexical prints
Message ID:
On Thu 20 Mar 2003 19:07, Spider Boardman <> wrote:
> 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.

Thanks. That explains it for me. Now let's hope I won't make that error again

H.Merijn Brand        Amsterdam Perl Mongers (
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
  WinNT 4, Win2K pro & WinCE 2.11.  Smoking perl CORE:
send smoke reports to:, QA:

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