David Gilden wrote:: ##this does not work....
:
: print ($sort_order) ? 'Newest First' : 'Oldest First';
Perl thinks you're doing this:
print($sort_order) ? 'Newest First' : 'Oldest First';
that is, it's taking $sort_order as an argument to print().
Either remove the parens:
print $sort_order ? 'Newest First' : 'Oldest First';
or put a plus in front of the opening paren, to show that you're just
using them for grouping and that print() shouldn't think that that's
its argument list:
print +($sort_order) ? 'Newest First' : 'Oldest First';
or you can specify STDOUT explicitly:
print STDOUT ($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
use printf with a specification of %02d (which means "2 digits padded
with leading zeros"):
printf TOFILE "On %02d/%02d/%4d At %02d:%02d you wrote:<br>\n\n",
$month, $day, $year, $hour, $min;
-- tdk