David Gilden wrote:
> Is there a way to combine the last two statements?
[...] 
> $sort_type = ($sort_order) ? 'Newest First' : 'Oldest First';
> # are the () optional?
> 
> print $sort_type;

        print $sort_order ? 'Newest First' : 'Oldest First';

or

        print( $sort_order ? 'Newest First' : 'Oldest First' );

(or

        print( ($sort_order) ? 'Newest First' : 'Oldest First' );

if you're bent on putting parens around your guard.)
 
> ##this does not work....
> 
> print ($sort_order) ? 'Newest First' : 'Oldest First';

The ()'s are taken to be the parameter list for print (print binds
more tightly than ?).
 
> ----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

        printf "On $month/$mday/$year At $hour:%02d you wrote:<br>\n\n",
$min;

Christian

__________________________________________________________________
117 NW 15th Street # S107                            [EMAIL PROTECTED]
Gainesville, FL  32603-1973                         (352) 392-0851

Reply via email to