In this case, it wont really matter. Since 1 and "1" is essentially the same.
If you were actually using a signed integer (in decimal), then you would see
the difference:
>From perldoc -f sprintf:
%s a string
%d a signed integer, in decimal
[root@fluffhead /]# perl -e 'printf "%04s\n
On Tue, Apr 24, 2001 at 01:09:13PM -0400, Kevin Meltzer wrote:
> Hi Susan,
>
> I get what you expect:
>
> perl -wle '$y=2001;$m=4;$d=5;printf("\%s%02s%02s.doc",$y,$m,$d)';
> 20010405.doc
[snip]
Well I'll be damned.
[ ~ ] perl -e 'printf "%04s\n", 1'
0001
[ ~ ] perl -e 'printf "%04s\n", "1"'
0
t: Re: Help on Date Format
Hi Susan,
I get what you expect:
perl -wle '$y=2001;$m=4;$d=5;printf("\%s%02s%02s.doc",$y,$m,$d)';
20010405.doc
Personally, I like POSIX.pm for dates.
# perl -MPOSIX -wle 'print strftime("%Y%m%d", localtime) . ".doc"'
Hi Susan,
I get what you expect:
perl -wle '$y=2001;$m=4;$d=5;printf("\%s%02s%02s.doc",$y,$m,$d)';
20010405.doc
Personally, I like POSIX.pm for dates.
# perl -MPOSIX -wle 'print strftime("%Y%m%d", localtime) . ".doc"';
20010424.doc
'perldoc POSIX' to learn more (look for strftime).
Cheers,
K
On Tue, Apr 24, 2001 at 11:00:40AM -0500, Arante, Susan wrote:
: Could someone tell me why this is happening? When I use this command, it
: used to give me 20010405.doc (mmdd.doc), now it's giving me 2001 4 5.doc
: - I'm losing the leading zeros.
: Command is on Perl 5 - printf("\%s%02s%02s
On Tue, Apr 24, 2001 at 11:00:40AM -0500, Arante, Susan wrote:
> Could someone tell me why this is happening? When I use this command, it
> used to give me 20010405.doc (mmdd.doc), now it's giving me 2001 4 5.doc
> - I'm losing the leading zeros.
> Command is on Perl 5 - printf("\%s%02s%02s
Could someone tell me why this is happening? When I use this command, it
used to give me 20010405.doc (mmdd.doc), now it's giving me 2001 4 5.doc
- I'm losing the leading zeros.
Command is on Perl 5 - printf("\%s%02s%02s.doc",$year,$month,$day).
Thanks.