[Perl] J'ai une variable qui varie toute seule...

Nicolas GEORGES xlat at cpan.org
Jeu 14 Sep 16:13:23 CEST 2017


Hello,
elle ne varie pas du tout, c'est juste que tu as confondu printf / sprintf
:-p

print
pack'b*',join'',map{$_.($_+0?'010':'100')}unpack('b*',pack'w*',7376,16,193516616,0,1508,0,11289860)=~/...../g
<http://codepad.org/Lb2tGEjj>


2017-09-14 15:02 GMT+01:00 Patrice Karatchentzeff <
patrice.karatchentzeff at gmail.com>:

> Salut,
>
> J'ai un truc que je ne pige pas. Voici un POC :
>
> % cat test.pl
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use English;
>
> my $ptime;
>
>
> $ptime = printTime();
> print  "$ptime : $ptime  grrrr\n";
> print  "toto $ptime : rrrggg\n";
>
>
> sub printTime {
>   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
>   my $time = printf("%02d:%02d:%02d", $hour, $min, $sec);
>   return $time;
> }
>
> % ./test.pl
> 16:00:561 : 1  grrrr
> toto 1 : rrrggg
>
> Pour quoi la variable ptime devient 1 dès son second emploi ?
>
> Merci
>
> PK
>
> --
>       |\      _,,,---,,_           Patrice KARATCHENTZEFF
> ZZZzz /,`.-'`'    -.  ;-;;,_   mailto:patrice.karatchentzeff at gmail.com
>      |,4-  ) )-,_. ,\ (  `'-'      http://p.karatchentzeff.free.fr
>     '---''(_/--'  `-'\_)
>
> _______________________________________________
> Perl mailing list
> Perl at mongueurs.net
> http://listes.mongueurs.net/mailman/listinfo/perl
>
>
-------------- section suivante --------------
Une pièce jointe HTML a été nettoyée...
URL: <http://listes.mongueurs.net/mailman/private/perl/attachments/20170914/7e838c3b/attachment-0001.html>


Plus d'informations sur la liste de diffusion Perl