[Purdue-pm] Why? Why? Why?

Dave Jacoby jacoby.david at gmail.com
Fri Apr 3 07:53:17 PDT 2020


Mentally, I wrote '00' not 00, but clearly I was in the rant, not checking
syntax.

:kicks self:

The question is, what's the point of using sprintf when you can just write
the string you want? I'm 90% sure it's cargo cult.

You can install Reply to get a repl, but perl -de 0 is cool as well.

On Fri, Apr 3, 2020 at 10:11 AM Mark Senn <mark at purdue.edu> wrote:

> > $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
>


-- 
Dave Jacoby
jacoby.david at gmail.com

I deal with my software the way I treat my eldritch abomination:
 It's not human, it's not even alive in the natural sense.
 It's nightmare-born and nightmare-shaped, and nightmares don't die easy.
  -- @yenzie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.pm.org/pipermail/purdue-pm/attachments/20200403/7098fbae/attachment-0001.html>


More information about the Purdue-pm mailing list