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

Re: $_ not optional with lexical prints

Thread Previous
From:
H.Merijn Brand
Date:
March 20, 2003 10:12
Subject:
Re: $_ not optional with lexical prints
Message ID:
20030320191132.DFDB.H.M.BRAND@hccnet.nl
On Thu 20 Mar 2003 19:07, Spider Boardman <nobody@web.zk3.dec.com> 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 (http://amsterdam.pm.org/)
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: smokers@perl.org
http://archives.develooper.com/daily-build@perl.org/   perl-qa@perl.org
send smoke reports to: smokers-reports@perl.org, QA: http://qa.perl.org



Thread Previous


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