[Purdue-pm] Why? Why? Why?

Mark Senn mark at purdue.edu
Fri Apr 3 07:11:50 PDT 2020


> $variable = 00;

00 evaluates to 0, I'd use
$variable = '00';

011 evaluates to 9---leading  0 means octal

I like to use perl -de 0 to explore stuff like this, e.g.,
$ perl -de 0
Loading DB routines from perl5db.pl version 1.53
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(-e:1):	0
  DB<1> $variable = sprintf("%02d", 0);
  DB<2> print $variable
00
  DB<3> $variable = 00;
  DB<4> print $variable
0

-mark


More information about the Purdue-pm mailing list