[plug] Perl, Sort, ctime.
James Bromberger
james at rcpt.to
Sat Oct 20 14:02:00 WST 2001
I know this is probably obvious, but for the Perl Mongers in PLUG,
here isa stupid problem i have had, and the solution. I had a
foreach loop to iterate over a set of times (as ctime), and was getting
some weird results:
my %stats;
$stats{time()} = "blah";
==> foreach my $time (sort keys %stats) {
The correction is:
foreach my $time (sort {$a <=> $b} keys %stats) {
Sort by default does an alphabetical sort, not numeric. Anyone want to
guess when these weird results started? Yep, September 9th, around 9:46am.
The One Billion seconds. Lexographically, 1000000000 < 999999999.
My graphs are again correct (no data was lost, just graphs not updated):
http://www.james.rcpt.to/programs/debian/incoming/
*sigh*
James
--
James Bromberger <james_AT_rcpt.to> www.james.rcpt.to
Remainder moved to http://www.james.rcpt.to/james/sig.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20011020/0ca9fb9d/attachment.pgp>
More information about the plug
mailing list