Remove the ()'s and it works.

For the 0's:
printf "On %02d/%02d/%04d At %02d:%02d you wrote:<br>\n\n", $month, $mday,
$year, $hour, $min;
see perldoc -f printf for more info.
----- Original Message -----
From: "David Gilden" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 01, 2001 1:05 PM
Subject: printf and other stuff


> Good afternoon,
>
> Is there a way to combine the last two statements?
>
> #!/usr/bin/perl -w
>
> $sort_order =0;
>
> $sort_type = ($sort_order) ? 'Newest First' : 'Oldest First';
> # are the () optional?
>
> print $sort_type;
>
>
> ##this does not work....
>
> print ($sort_order) ? 'Newest First' : 'Oldest First';
>
> ----printf question--
>
> ### get time
> my($sec, $min, $hour, $mday, $month, $year) = (localtime)[0..5];
> $year += 1900;
> $mday = "0" . $mday if $mday < 10;
> $month++; # perl counts from -1 on occasion
> $month = "0" . $month if $month < 10;
> ####
>
> -- later in the same file --
>
> print TOFILE "On $month/$mday/$year At $hour:$min you wrote:<br>\n\n";
>
> how do I use print to provide a leading '0' to $min, such that
> I get 5:01 and not 5:1
>
>
> Thanks!
>
> Dave G.
>
>

Reply via email to