[32824] in Perl-Users-Digest
Perl-Users Digest, Issue: 4089 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 4 03:09:34 2013
Date: Wed, 4 Dec 2013 00:09:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 4 Dec 2013 Volume: 11 Number: 4089
Today's topics:
weird hash sort question <cartercc@gmail.com>
Re: weird hash sort question <bjoern@hoehrmann.de>
Re: weird hash sort question <ben@morrow.me.uk>
Re: weird hash sort question <ben@morrow.me.uk>
Re: weird hash sort question <bjoern@hoehrmann.de>
Re: weird hash sort question <jurgenex@hotmail.com>
Re: weird hash sort question <rweikusat@mobileactivedefense.com>
Re: weird hash sort question <cartercc@gmail.com>
Re: weird hash sort question <cwilbur@chromatico.net>
Re: weird hash sort question <ben@morrow.me.uk>
Re: What date was so many months and years before <gamo@telecable.es>
Re: What date was so many months and years before <cwilbur@chromatico.net>
Re: What date was so many months and years before <jurgenex@hotmail.com>
Re: What date was so many months and years before <jurgenex@hotmail.com>
Re: What date was so many months and years before <ben@morrow.me.uk>
Re: What date was so many months and years before <cwilbur@chromatico.net>
Re: What date was so many months and years before <bill@todbe.com>
Re: What date was so many months and years before <ben@morrow.me.uk>
Re: What date was so many months and years before <bill@todbe.com>
Re: What date was so many months and years before <gamo@telecable.es>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Dec 2013 14:27:47 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: weird hash sort question
Message-Id: <c4996c91-8d75-4b04-802a-47e62c3390eb@googlegroups.com>
my @teams = ("Florida State","Ohio State","Auburn","Alabama" ...)
my %ratings;
#example values of %ratings
$ratings{BCS}{"Florida State"}{...}{...} = 'some value';
$ratings{BCS}{"Ohio State"}{...}{...} = 'some value';
$ratings{BCS}{"Auburn"}{...}{...} = 'some value';
$ratings{BCS}{"Alabama"}{...}{...} = 'some value';
$ratings{BCS}{...}{...}{...} = 'some value';
$ratings{...}{...}{...}{...} = 'some value';
foreach my $bowl (sort keys %ratings)
{
foreach my $team (sort keys %{$ratings->{$bowl}}
{
foreach my $somekey (sort keys %{$ratings->{$bowl}{etc}})
{
#doesn't matter
}
}
}
This sort routine gives values like:
BCS
Alabama
Auburn
Florida State
Ohio State
Harris
etc, etc, and etc.
WHAT I WANT IS THIS !!!!!
BCS
Florida State
Ohio State
Auburn
Alabama
Harris
etc, etc, and etc.
What I'd like to do (but doesn't work) is this:
foreach my $bowl (sort keys %ratings) # this is okay
foreach my $team (sort (@teams) keys %{$ratings->{$bowl})
{
#okay from here on out
}
}
Suggestions?
Thanks very, very much, CC.
------------------------------
Date: Tue, 03 Dec 2013 23:57:35 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: weird hash sort question
Message-Id: <c5os991ptdhtpidjrta6mbs6oqb2543gh6@hive.bjoern.hoehrmann.de>
* ccc31807 wrote in comp.lang.perl.misc:
>my @teams = ("Florida State","Ohio State","Auburn","Alabama" ...)
You can do something like this
my %team_sortkey = do {
my $i = 1;
map { $_ => $i++ } @teams;
};
That creates a hash like
"Florida State" => 1,
"Ohio State" => 2,
...
Then later sort by comparing the mapped values like
sort { $team_sortkey{$a} <=> $team_sortkey{$b} } @list_of_teams;
I believe there are CPAN modules that aid in sorting multi-dimensional
hashes as well as key-based sorting. For instance, my `List::OrderBy`
module would let you write
order_by { $team_sortkey{$_} } @list_of_teams;
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
------------------------------
Date: Tue, 3 Dec 2013 23:58:52 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: weird hash sort question
Message-Id: <sq72na-m9s.ln1@anubis.morrow.me.uk>
Quoth derhoermi@gmx.net:
> * ccc31807 wrote in comp.lang.perl.misc:
> >my @teams = ("Florida State","Ohio State","Auburn","Alabama" ...)
>
> You can do something like this
>
> my %team_sortkey = do {
> my $i = 1;
> map { $_ => $i++ } @teams;
> };
>
> That creates a hash like
>
> "Florida State" => 1,
> "Ohio State" => 2,
> ...
>
> Then later sort by comparing the mapped values like
>
> sort { $team_sortkey{$a} <=> $team_sortkey{$b} } @list_of_teams;
Um, no, there's a *much* easier answer...
(Assuming, of course, that @teams is complete. If it isn't it gets a
little harder.)
Ben
------------------------------
Date: Tue, 3 Dec 2013 23:56:16 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: weird hash sort question
Message-Id: <0m72na-m9s.ln1@anubis.morrow.me.uk>
Quoth ccc31807 <cartercc@gmail.com>:
> my @teams = ("Florida State","Ohio State","Auburn","Alabama" ...)
[...]
>
> foreach my $bowl (sort keys %ratings)
> {
> foreach my $team (sort keys %{$ratings->{$bowl}}
[...]
>
> This sort routine gives values like:
> BCS
> Alabama
> Auburn
> Florida State
> Ohio State
> Harris
> etc, etc, and etc.
>
> WHAT I WANT IS THIS !!!!!
> BCS
> Florida State
> Ohio State
> Auburn
> Alabama
> Harris
> etc, etc, and etc.
>
> What I'd like to do (but doesn't work) is this:
> foreach my $bowl (sort keys %ratings) # this is okay
> foreach my $team (sort (@teams) keys %{$ratings->{$bowl})
> {
Stop and think about what you're doing for a minute, instead of just
retyping code you've written before. What does
keys %{$ratings->{$bowl}}
return? What does sort do to that list? What will $team be set to each
time round the loop?
Now, how does the list you have in @teams compare with any of those
things?
Ben
------------------------------
Date: Wed, 04 Dec 2013 01:18:19 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: weird hash sort question
Message-Id: <alss99l4ibmavujl47kcbaomfqo29nksgq@hive.bjoern.hoehrmann.de>
* Ben Morrow wrote in comp.lang.perl.misc:
>Quoth derhoermi@gmx.net:
>> * ccc31807 wrote in comp.lang.perl.misc:
>> >my @teams = ("Florida State","Ohio State","Auburn","Alabama" ...)
>>
>> You can do something like this
>>
>> my %team_sortkey = do {
>> my $i = 1;
>> map { $_ => $i++ } @teams;
>> };
>> Then later sort by comparing the mapped values like
>>
>> sort { $team_sortkey{$a} <=> $team_sortkey{$b} } @list_of_teams;
>
>Um, no, there's a *much* easier answer...
>
>(Assuming, of course, that @teams is complete. If it isn't it gets a
>little harder.)
Iterating over @teams does not sort the keys in the hash, so you are
more likely to end up with bugs later on without necessarily noticing
it at first, so I would not necessarily recommend doing that.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
------------------------------
Date: Tue, 03 Dec 2013 17:08:37 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: weird hash sort question
Message-Id: <gdvs99t55ilfa565dsfcpkkvb08dao6tjm@4ax.com>
Bjoern Hoehrmann <bjoern@hoehrmann.de> wrote:
>* Ben Morrow wrote in comp.lang.perl.misc:
>>Quoth derhoermi@gmx.net:
>>> * ccc31807 wrote in comp.lang.perl.misc:
>>> >my @teams = ("Florida State","Ohio State","Auburn","Alabama" ...)
>>>
>>> You can do something like this
>>>
>>> my %team_sortkey = do {
>>> my $i = 1;
>>> map { $_ => $i++ } @teams;
>>> };
>
>>> Then later sort by comparing the mapped values like
>>>
>>> sort { $team_sortkey{$a} <=> $team_sortkey{$b} } @list_of_teams;
>>
>>Um, no, there's a *much* easier answer...
>>
>>(Assuming, of course, that @teams is complete. If it isn't it gets a
>>little harder.)
>
>Iterating over @teams does not sort the keys in the hash, so you are
You can never sort the keys in a hash. At most you can sort the keys of
a hash.
>more likely to end up with bugs later on without necessarily noticing
>it at first, so I would not necessarily recommend doing that.
And the usual way to sort by a custom criteria is to define a custom
function that returns -1, 0, or 1 depending upon if the left argument is
smaller, the same, or a larger than the right argument (aka $a and $b).
In this case here it appears the OP wants to sort his data by the
sequence defined in @teams. If so (guessing here, he didn't say so
explicitely) then we need a custom compare function for those elements.
The OP can either define that from scratch or leverage the existing
sequence in @teams using e.g. firstidx() from List::MoreUtils or use one
of the many other approaches described at
http://www.perlmonks.org/?node_id=75660.
While this may not be very efficient it is a well-designed and clean
approach. If you are looking for a more efficient way then I think
applying a Schwartzian Transformation may be called for.
jue
------------------------------
Date: Wed, 04 Dec 2013 01:15:23 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: weird hash sort question
Message-Id: <87fvq9ct78.fsf@sable.mobileactivedefense.com>
Ben Morrow <ben@morrow.me.uk> writes:
> Quoth ccc31807 <cartercc@gmail.com>:
>> my @teams = ("Florida State","Ohio State","Auburn","Alabama" ...)
> [...]
>>
>> foreach my $bowl (sort keys %ratings)
>> {
>> foreach my $team (sort keys %{$ratings->{$bowl}}
> [...]
>>
>> This sort routine gives values like:
>> BCS
>> Alabama
>> Auburn
>> Florida State
>> Ohio State
>> Harris
>> etc, etc, and etc.
>>
>> WHAT I WANT IS THIS !!!!!
>> BCS
>> Florida State
>> Ohio State
>> Auburn
>> Alabama
>> Harris
>> etc, etc, and etc.
>>
>> What I'd like to do (but doesn't work) is this:
>> foreach my $bowl (sort keys %ratings) # this is okay
>> foreach my $team (sort (@teams) keys %{$ratings->{$bowl})
>> {
>
> Stop and think about what you're doing for a minute, instead of just
> retyping code you've written before. What does
>
> keys %{$ratings->{$bowl}}
>
> return?
A set of unknown strings, probably containing 'Florida State', 'Ohio
State', 'Auburn', 'Alabama' and 'etc, etc. and etc.'.
> What does sort do to that list?
It probably reorders it somehow.
> What will $team be set to each time round the loop?
To some string.
> Now, how does the list you have in @teams compare with any of those
> things?
It contains strings as well.
The only sensible question here is "What are you trying to do?" and the
answer must not be pseudo-Perl not even the author considers to be
adequate to describe that.
------------------------------
Date: Tue, 3 Dec 2013 19:28:39 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: weird hash sort question
Message-Id: <a0c62aa6-b903-4dca-9332-9baed059e2ad@googlegroups.com>
On Tuesday, December 3, 2013 8:15:23 PM UTC-5, Rainer Weikusat wrote:
> > Stop and think about what you're doing for a minute, instead of just
> > retyping code you've written before. What does
> > keys %{$ratings->{$bowl}}
> > return?
> A set of unknown strings, probably containing 'Florida State', 'Ohio
> State', 'Auburn', 'Alabama' and 'etc, etc. and etc.'.
> > What does sort do to that list?
> It probably reorders it somehow.
> > What will $team be set to each time round the loop?
> To some string.
> > Now, how does the list you have in @teams compare with any of those
> > things?
> It contains strings as well.
> The only sensible question here is "What are you trying to do?" and the
> answer must not be pseudo-Perl not even the author considers to be
> adequate to describe that.
SOLVED!!!!
And yeah, I'm kind of excited. I spent most of the afternoon on this instead of working, and got frustrated. My test program and output follows. Comments and criticisms humbly accepted.
#-------------------sorthash.plx-------------------
#! perl
use strict;
use warnings;
use List::MoreUtils qw ( indexes );
use v5.10;
say qq(sorting hash values.........);
my @campi = qw( T01 M01 D01 ETROY GC T02);
foreach (@campi) { print " $_ "; }
print "\n";
my %h = (
M01 => 44,
T01 => 456,
ETROY => 342,
GC => 498,
T02 => 9,
D01 => 108,
);
foreach my $k (sort keys %h) { say "$k => $h{$k}"; }
print "-----------------------------\n";
foreach my $k (sort { $h{$a} <=> $h{$b} } keys %h) { say "$k => $h{$k}"; }
print "-----------------------------\n";
foreach my $k (sort {
my $x = indexes {$_ eq $a} @campi;
my $y = indexes {$_ eq $b} @campi;
#print "a $a b $b x $x y $y\n";
$x > $y ? 1 : -1 ;
} keys %h) { say "$k => $h{$k}"; }
exit(0);
#----------------output--------------
>perl sorthash.plx
sorting hash values.........
T01 M01 D01 ETROY GC T02
D01 => 108
ETROY => 342
GC => 498
M01 => 44
T01 => 456
T02 => 9
-----------------------------
T02 => 9
M01 => 44
D01 => 108
ETROY => 342
T01 => 456
GC => 498
-----------------------------
T01 => 456
M01 => 44
D01 => 108
ETROY => 342
GC => 498
T02 => 9
------------------------------
Date: Tue, 03 Dec 2013 22:43:22 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: weird hash sort question
Message-Id: <87y541l1r9.fsf@new.chromatico.net>
>>>>> "RW" == Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
>> Now, how does the list you have in @teams compare with any of
>> those things?
RW> It contains strings as well.
It contains the keys of the hash, in the order the OP wants them to
appear in for display.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Wed, 4 Dec 2013 05:54:09 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: weird hash sort question
Message-Id: <1ls2na-s411.ln1@anubis.morrow.me.uk>
Quoth Jürgen Exner <jurgenex@hotmail.com>:
> Bjoern Hoehrmann <bjoern@hoehrmann.de> wrote:
> >* Ben Morrow wrote in comp.lang.perl.misc:
> >>
> >>Um, no, there's a *much* easier answer...
> >>
> >>(Assuming, of course, that @teams is complete. If it isn't it gets a
> >>little harder.)
> >
> >Iterating over @teams does not sort the keys in the hash, so you are
>
> You can never sort the keys in a hash. At most you can sort the keys of
> a hash.
>
> >more likely to end up with bugs later on without necessarily noticing
> >it at first, so I would not necessarily recommend doing that.
>
> And the usual way to sort by a custom criteria is to define a custom
> function that returns -1, 0, or 1 depending upon if the left argument is
> smaller, the same, or a larger than the right argument (aka $a and $b).
>
> In this case here it appears the OP wants to sort his data by the
> sequence defined in @teams. If so (guessing here, he didn't say so
> explicitely) then we need a custom compare function for those elements.
> The OP can either define that from scratch or leverage the existing
> sequence in @teams using e.g. firstidx() from List::MoreUtils or use one
> of the many other approaches described at
> http://www.perlmonks.org/?node_id=75660.
Again, this is much too complicated. @teams already contains a sorted
list of keys to process, so just iterate over that. If there might be
keys in the array which are not present in the hash, that's trivial to
handle (and will probably fall out of the processing naturally). If
there are keys in the hash which aren't in the array none of these fancy
solutions will help: the OP would need to define how such keys should be
sorted, and probably the best solution would be to extend @teams
beforehand to include the new keys.
Ben
------------------------------
Date: Mon, 02 Dec 2013 14:32:28 +0100
From: gamo <gamo@telecable.es>
Subject: Re: What date was so many months and years before
Message-Id: <l7i25e$kom$1@speranza.aioe.org>
El 01/12/13 10:00, Jürgen Exner escribió:
> And when you do have your dates in some normalized format, then just
> convert both into seconds since the epoch, compute the difference, and
> divide by 24*60*60.
> This is close enough for all practical purposes because when your output
> unit is days then you don't care about leap seconds or hours
> added/removed by summer time.
>
> jue
perldoc -f time mentions the DateTime module. Anyway, there is a
problem with the epoch, that is a too recent date. I.e. if I want
to calculate my age in days I think it's better to count over the
actual calendar (gregorian). :-(
Thanks
------------------------------
Date: Mon, 02 Dec 2013 10:32:36 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: What date was so many months and years before
Message-Id: <8738mbp8tn.fsf@new.chromatico.net>
>>>>> "RW" == Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
RW> Replacing a small amount of 'awkward code' with a large amount
RW> of 'awkward code' isn't necessarily an improvement.
Replacing a small amount of incorrect code with a large amount of
correct code, however, is a significant improvement.
Your allergy to code other people have written is puzzling; why are you
not writing directly in x86 assembler?
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Mon, 02 Dec 2013 08:22:34 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: What date was so many months and years before
Message-Id: <3rcp99lcp7p9bkajd2a7k6h7vu8him4g4v@4ax.com>
Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
>Jürgen Exner <jurgenex@hotmail.com> writes:
>> George Mpouras <gravitalsun@foo.com> wrote:
>>>#I want the calendar date of any number of years/months before.
>>># Currently I use the following, but maybe there is a better way.
>>
>> Is there anything wrong with Date::Calc?
>>
>> [long, awkward code snipped]
>
>Replacing a small amount of 'awkward code' with a large amount of
>'awkward code' isn't necessarily an improvement.
In my book a
use Date::Calc;
is significantly shorter than anything the OP wrote. Besides, chances
are much higher that it is correct.
But of course you are welcome to your own believes.
jue
------------------------------
Date: Mon, 02 Dec 2013 08:03:46 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: What date was so many months and years before
Message-Id: <pobp99p3rts9gvmvq8bdsf69pg8k38hqds@4ax.com>
gamo <gamo@telecable.es> wrote:
>El 01/12/13 10:00, Jürgen Exner escribió:
>> And when you do have your dates in some normalized format, then just
>> convert both into seconds since the epoch, compute the difference, and
>> divide by 24*60*60.
>> This is close enough for all practical purposes because when your output
>> unit is days then you don't care about leap seconds or hours
>> added/removed by summer time.
>>
>> jue
>
>perldoc -f time mentions the DateTime module. Anyway, there is a
>problem with the epoch, that is a too recent date. I.e. if I want
>to calculate my age in days I think it's better to count over the
>actual calendar (gregorian). :-(
If time since epoch is a signed integer then that would be no problem,
either.
jue
------------------------------
Date: Mon, 2 Dec 2013 16:45:33 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: What date was so many months and years before
Message-Id: <d2quma-3ve.ln1@anubis.morrow.me.uk>
Quoth gamo <gamo@telecable.es>:
> El 01/12/13 10:00, Jürgen Exner escribió:
> > And when you do have your dates in some normalized format, then just
> > convert both into seconds since the epoch, compute the difference, and
> > divide by 24*60*60.
> > This is close enough for all practical purposes because when your output
> > unit is days then you don't care about leap seconds or hours
> > added/removed by summer time.
>
> perldoc -f time mentions the DateTime module.
DateTime is the 'big guns' when it comes to date and time manipulation
in Perl. It does everything, and it does it right, but it's also quite a
large chunk of code. IME it's usually simpler just to use it anyway,
though.
> Anyway, there is a
> problem with the epoch, that is a too recent date. I.e. if I want
> to calculate my age in days I think it's better to count over the
> actual calendar (gregorian). :-(
'Seconds since the epoch' also covers 'seconds before the epoch',
through the magic of negative numbers. In fact, on my system, perl will
go back as far as
~% perl -E'say scalar gmtime -(1<<52)'
Mon Jan 25 20:11:44 -142711421
(that's 143 million BC; some time in the early Cretaceous) with second
precision; presumably it's using 53bit floats underneath.
Ben
------------------------------
Date: Mon, 02 Dec 2013 16:01:53 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: What date was so many months and years before
Message-Id: <871u1vnf0e.fsf@new.chromatico.net>
>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:
BM> DateTime is the 'big guns' when it comes to date and time
BM> manipulation in Perl. It does everything, and it does it right,
BM> but it's also quite a large chunk of code. IME it's usually
BM> simpler just to use it anyway, though.
Simpler and wiser; the first time your code screws up because the
legislative entity in your country changed the dates for Daylight
Savings Time or British Summer Time or whatever it's called in your
locale, you will have wasted more time than just using DateTime.
Assuming you got the time change right in the first place, that is. I
worked for a place (years ago) that had custom date handling code.
Twice a year we could count on customer service nightmares because no
two systems handled daylight savings time in the same way, never mind
correctly.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Mon, 02 Dec 2013 16:23:34 -0800
From: "$Bill" <bill@todbe.com>
Subject: Re: What date was so many months and years before
Message-Id: <l7j8a2$5pi$1@dont-email.me>
On 12/2/2013 08:03, Jürgen Exner wrote:
> gamo <gamo@telecable.es> wrote:
>
>> perldoc -f time mentions the DateTime module. Anyway, there is a
>> problem with the epoch, that is a too recent date. I.e. if I want
>> to calculate my age in days I think it's better to count over the
>> actual calendar (gregorian). :-(
>
> If time since epoch is a signed integer then that would be no problem,
> either.
Has to be unsigned if it goes to 2038 and you're on a 32 bitter. :)
------------------------------
Date: Tue, 3 Dec 2013 08:28:50 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: What date was so many months and years before
Message-Id: <2bh0na-5vm.ln1@anubis.morrow.me.uk>
Quoth "$Bill" <bill@todbe.com>:
> On 12/2/2013 08:03, Jürgen Exner wrote:
> > gamo <gamo@telecable.es> wrote:
> >
> >> perldoc -f time mentions the DateTime module. Anyway, there is a
> >> problem with the epoch, that is a too recent date. I.e. if I want
> >> to calculate my age in days I think it's better to count over the
> >> actual calendar (gregorian). :-(
> >
> > If time since epoch is a signed integer then that would be no problem,
> > either.
>
> Has to be unsigned if it goes to 2038 and you're on a 32 bitter. :)
Even 32bit machines have floating point numbers which provide 53 bits of
integer accuracy. Since 5.12 perl has used its own implementation of the
time_t functions which uses floats on 32bit machines to handle dates
beyond 2038.
(And 'dates after 2038' is the problem, not 'dates before 1970'. time_t
has always been signed.)
Ben
------------------------------
Date: Tue, 03 Dec 2013 02:20:07 -0800
From: "$Bill" <bill@todbe.com>
Subject: Re: What date was so many months and years before
Message-Id: <l7kb8l$rue$1@dont-email.me>
On 12/3/2013 00:28, Ben Morrow wrote:
>
> Quoth "$Bill" <bill@todbe.com>:
>>
>> Has to be unsigned if it goes to 2038 and you're on a 32 bitter. :)
>
> Even 32bit machines have floating point numbers which provide 53 bits of
> integer accuracy. Since 5.12 perl has used its own implementation of the
> time_t functions which uses floats on 32bit machines to handle dates
> beyond 2038.
True, but I was referring to the standard UNIX time functions which
were/are all integer arithmetic - not a Perl workaround.
Remember the Y2K issues - the next issue would have been the 2038
issue, but by then the computers will all be like 248 bitters. ;)
> (And 'dates after 2038' is the problem, not 'dates before 1970'. time_t
> has always been signed.)
------------------------------
Date: Tue, 03 Dec 2013 12:04:19 +0100
From: gamo <gamo@telecable.es>
Subject: Re: What date was so many months and years before
Message-Id: <l7kdri$94c$1@speranza.aioe.org>
El 03/12/13 11:20, $Bill escribió:
> Remember the Y2K issues - the next issue would have been the 2038
> issue, but by then the computers will all be like 248 bitters. ;)
256 bits. Maybe. But the clock speed in Ghz seems difficult to
improve, comparing to the number of processor's cores. The branch
of the optical computers seems a dead way. I don't expect to
see what happens that year, but I predict that nobody will be
impressed with computers as we are today. Maybe the key will be
brain-machines interfaces.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 4089
***************************************