develooper Front page | perl.perl5.porters | Postings from September 2016

Re: [perl #129757] for loop doesn't update correct variable

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
September 29, 2016 01:23
Subject:
Re: [perl #129757] for loop doesn't update correct variable
Message ID:
20160929012345.GA4032@debian
* James E Keenan via RT <perlbug-followup@perl.org> [2016-09-28T21:05:02]
> Why, in a similar circumstance, does 'print' behave differently from 'printf'?

  ~$ perl -e 'my $x = undef; printf "%d\n", $x'
  0
  ~$ perl -e 'my $x = undef; print "$x\n"'


The %d format numifies undef.

  ~$ perl -Mwarnings -e 'my $x = undef; printf "%d\n", $x'
  Use of uninitialized value $x in printf at -e line 1.
  0
  ~$ perl -Mwarnings -e 'my $x = undef; print "$x\n"'
  Use of uninitialized value $x in concatenation (.) or string at -e line 1.

-- 
rjbs

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