Re: printf and other stuff

2001-06-05 Thread Rob Hanz
Michael Fowler wrote: > On Tue, Jun 05, 2001 at 08:05:24AM -0400, Herb Hall wrote: > > $min = "0" . $min if $min < 10; > > > > will pad your minutes with a 0. I have used both methods for various > > reasons. You probably only need to use one or the other. I would use the > > printf unless you hav

Re: printf and other stuff

2001-06-05 Thread Michael Fowler
On Tue, Jun 05, 2001 at 08:05:24AM -0400, Herb Hall wrote: > $min = "0" . $min if $min < 10; > > will pad your minutes with a 0. I have used both methods for various > reasons. You probably only need to use one or the other. I would use the > printf unless you have some need to have the variables

RE: printf and other stuff

2001-06-05 Thread Herb Hall
> ### 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/$y

Re: printf and other stuff

2001-06-01 Thread Timothy Kimball
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_ord

Re: printf and other stuff

2001-06-01 Thread Christian Campbell
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 Fi

Re: printf and other stuff

2001-06-01 Thread Me
I'll just answer the 'other stuff'. > ##this does not work > > print ($sort_order) ? 'Newest First' : 'Oldest First'; Perl sees this as a function() call followed by the rest. Instead, do: > print $sort_order ? 'Newest First' : 'Oldest First'; In general, Perl works to minimize the numbe

Re: printf and other stuff

2001-06-01 Thread Jeff Pinyan
On Jun 1, David Gilden said: >$sort_order =0; > >$sort_type = ($sort_order) ? 'Newest First' : 'Oldest First'; ># are the () optional? In this case, yes, you don't need those parens. >print ($sort_order) ? 'Newest First' : 'Oldest First'; Remove the parens, or add them around the entire argume

Re: printf and other stuff

2001-06-01 Thread John Joseph Trammell
On Fri, Jun 01, 2001 at 03:05:59PM -0400, David Gilden wrote: [snip -- was there a question about '?:' ?] > 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 fr

Re: printf and other stuff

2001-06-01 Thread Ken
Remove the ()'s and it works. For the 0's: printf "On %02d/%02d/%04d At %02d:%02d you wrote:\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