On Sat, Nov 29, 2008 at 21:25, David <[EMAIL PROTECTED]> wrote:
> I am trying to get 081129 into $dayStamp.
>
> #!/usr/bin/perl -w
> use strict;
> my $dayStamp;
> $dayStamp = `date +\'%y%m%d\'` && die "Failure!";
> print "$dayStamp\n";
>
>
> My program outputs:
> Failure! at /Users/dave/perl/dateLogger01.pl line 4.
>
> I thought I did every conceivable combination of backticks and double quotes
> allowable. I'm quite stuck.
snip

Using external programs when that is not the main purpose of the
program is generally a bad idea.  Luckily the tools you need are part
of Core Perl:

#!/usr/bin/perl

use strict;
use warnings;
use POSIX qw(strftime);

#FIXME: give serious consideration to using %Y
#instead of %y, two digit years are not good
my $dayStamp = strftime "%y%m%d", localtime;
print "$dayStamp\n";


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to