[25331] in Perl-Users-Digest
Perl-Users Digest, Issue: 7576 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 27 11:05:47 2004
Date: Mon, 27 Dec 2004 08:05:13 -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 Mon, 27 Dec 2004 Volume: 10 Number: 7576
Today's topics:
Calculation/Comparison on Date <sam.wun@authtec.com>
Re: Calculation/Comparison on Date jkeen_via_google@yahoo.com
copying values from a hash into CGI.pm via tied hash re ioneabu@yahoo.com
Re: copying values from a hash into CGI.pm via tied has <mritty@gmail.com>
Re: copying values from a hash into CGI.pm via tied has <matthew.garrish@sympatico.ca>
Re: copying values from a hash into CGI.pm via tied has ioneabu@yahoo.com
how to delete files that create date <=20041210 <sonet.all@msa.hinet.net>
Re: Is zero even or odd? <jfields@austininstruments.com>
Re: Is zero even or odd? <jfields@austininstruments.com>
Re: Is zero even or odd? <mkent@acm.org>
Re: Is zero even or odd? <gweast@mathworks.com>
Re: Is zero even or odd? <george@briar.demon.co.uk>
Re: need help in programming linux with perl <Donald.Shimoda@nospam.on.cox.net>
Pretty Printing (maybe with PDFs ?) colin@beyondboxes.com
Re: Pretty Printing (maybe with PDFs ?) <bik.mido@tiscalinet.it>
Re: Pretty Printing (maybe with PDFs ?) <shawn.corey@sympatico.ca>
Re: retrieving Hash elements <gbh04@tiscali.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 27 Dec 2004 22:18:11 +0800
From: sam <sam.wun@authtec.com>
Subject: Calculation/Comparison on Date
Message-Id: <cqp74t$2pk9$1@news.hgc.com.hk>
Hi,
I m wondering whether there is existing perl module provide functions
for calculating date and comparison of two dates.
I need to take a user input date and will subtract it by 1,3,6 or 12
months. As the requirement only care about YYYY-MM, so I will need to
know the form of starting date and ending date (YYYY-MM-DD) after the
substraction. In this case, the starting date should be in the form of
YYYY-MM-01 and ending date is YYYY-MM-28,29,30 or 31.
Thanks
Sam
------------------------------
Date: 27 Dec 2004 06:34:28 -0800
From: jkeen_via_google@yahoo.com
Subject: Re: Calculation/Comparison on Date
Message-Id: <1104158068.931327.93600@z14g2000cwz.googlegroups.com>
sam wrote:
> Hi,
>
> I m wondering whether there is existing perl module provide functions
> for calculating date and comparison of two dates.
>
> I need to take a user input date and will subtract it by 1,3,6 or 12
> months. As the requirement only care about YYYY-MM, so I will need to
> know the form of starting date and ending date (YYYY-MM-DD) after the
> substraction. In this case, the starting date should be in the form
of
> YYYY-MM-01 and ending date is YYYY-MM-28,29,30 or 31.
>
CPAN is your friend. See the Date::* and DateTime::* namespaces. My
personal favorite is Date::Calc
(http://cpan.uwinnipeg.ca/module/Date::Calc). For your task, I would
look at the Date::Calc functions whose names begin with Delta_ or
Add_Delta_.
Jim Keenan
------------------------------
Date: 27 Dec 2004 06:02:47 -0800
From: ioneabu@yahoo.com
Subject: copying values from a hash into CGI.pm via tied hash reference
Message-Id: <1104156167.901423.152830@f14g2000cwb.googlegroups.com>
I am trying to restore values from a saved session to fill in my CGI.pm
fields in the simplest and most generic way possible (such that if I
change my form, I don't have to rewrite this code). This statement did
not work:
$params->{keys %session} = values %session;
$params is a reference to a tied hash returned by Vars().
Here is info on Vars() quoted from
http://stein.cshl.org/WWW/software/CGI/
<quote>
Many people want to fetch the entire parameter list as a hash in which
the keys are the names of the CGI parameters, and the values are the
parameters' values. The Vars() method does this. Called in a scalar
context, it returns the parameter list as a tied hash reference.
Changing a key changes the value of the parameter in the underlying CGI
parameter list. Called in an list context, it returns the parameter
list as an ordinary hash. This allows you to read the contents of the
parameter list, but not to change it.
</quote>
Thanks for help. I know I could do it differently, I was just
wondering why it didn't work this way.
wana
------------------------------
Date: Mon, 27 Dec 2004 15:36:28 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: copying values from a hash into CGI.pm via tied hash reference
Message-Id: <0_Vzd.9025$He3.8101@trndny05>
<ioneabu@yahoo.com> wrote in message
news:1104156167.901423.152830@f14g2000cwb.googlegroups.com...
> I am trying to restore values from a saved session to fill in my
CGI.pm
> fields in the simplest and most generic way possible (such that if I
> change my form, I don't have to rewrite this code). This statement
did
> not work:
"did not work" is a remarkably poor error description. What did it do?
What were you expecting/hoping for it to do? How did the results
differ?
Have you read the posting guidelines that are posted to this group
semi-weekly?
> $params->{keys %session} = values %session;
You are using the keys function in a scalar context. In scalar context,
keys returns the number of keys in the given hash. Therefore, if
%session contained two key/value pairs, this is the equivalent of
$params->{2} = 2; #since values in scalar context also returns the
number of pairs
What you want to do is create a hash slice and assign to that. If you
had a normal hash, say:
my %hash;
you would generate the slice like so:
@hash{foo,bar} = ( ... );
The general rule when dealing with hashrefs is to replace the name of
the hash ('hash' in this case) with the hashref, in brackets. Thus
%hash becomes %{$params}
and
@hash{foo,bar} becomes @($params}{foo,bar);
Putting it all together, here's a short example script to demonstrate
the correct technique:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
#fill %session with dummy data
my %session = (foo=>1,bar=>2);
#create anon hash reference
my $params = { };
#create a hashslice and use it to populate the anon hash
@{$params}{keys %session} = values %session;
print Dumper($params);
__END__
$VAR1 = {
'bar' => 2,
'foo' => 1
};
Hope this helps,
Paul Lalli
------------------------------
Date: Mon, 27 Dec 2004 10:31:48 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: copying values from a hash into CGI.pm via tied hash reference
Message-Id: <yVVzd.12015$Tn1.363027@news20.bellglobal.com>
<ioneabu@yahoo.com> wrote in message
news:1104156167.901423.152830@f14g2000cwb.googlegroups.com...
>I am trying to restore values from a saved session to fill in my CGI.pm
> fields in the simplest and most generic way possible (such that if I
> change my form, I don't have to rewrite this code). This statement did
> not work:
>
> $params->{keys %session} = values %session;
>
> $params is a reference to a tied hash returned by Vars().
>
> Thanks for help. I know I could do it differently, I was just
> wondering why it didn't work this way.
>
You can't just write something you don't understand and expect it to work:
"keys %session" returns the number of keys in %session in scalar context and
"values %session" returns the number of values (see perlfunc). So, assuming
to two key/value pairs in %session, your statement becomes:
$params->{2} = 2;
If you don't use some kind of loop, you're never going to get what you want:
foreach (keys %session) { $params->{$_} = $session{$_} }
Matt
------------------------------
Date: 27 Dec 2004 08:01:35 -0800
From: ioneabu@yahoo.com
Subject: Re: copying values from a hash into CGI.pm via tied hash reference
Message-Id: <1104163295.020784.314140@f14g2000cwb.googlegroups.com>
Sorry for saying 'did not work.'
Here is what I tried:
$params->{keys %session} = values %session;
Here is the example I based it on:
http://www.unix.org.ua/orelly/perl/learn/ch05_05.htm
<quote>
Hash slices can also be used to merge a smaller hash into a larger one.
In this example, the smaller hash takes precedence in the sense that if
there are duplicate keys, the value from the smaller hash is used:
%league{keys %score} = values %score;
</quote>
Maybe this was the source of my confusion. I thought I understood the
example but now I am not sure.
------------------------------
Date: Tue, 28 Dec 2004 00:00:42 +0800
From: "sonet" <sonet.all@msa.hinet.net>
Subject: how to delete files that create date <=20041210
Message-Id: <cqpbk9$f00$1@netnews.hinet.net>
I can scan the dir and get all file create date.
if create date<=20041210 to delete this file.
EX:
#!/usr/bin/perl
$a='file';
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat("$a");
print $ctime;
But have any other good method to do this job??
------------------------------
Date: Mon, 27 Dec 2004 05:30:08 -0600
From: John Fields <jfields@austininstruments.com>
Subject: Re: Is zero even or odd?
Message-Id: <ufsvs0pbvnsfmpssnj7lbrtk85hvls7823@4ax.com>
On Sun, 26 Dec 2004 22:24:18 +0000, John Woodgate
<jmw@jmwa.demon.contraspam.yuk> wrote:
>I read in sci.electronics.design that John Fields <jfields@austininstrum
>ents.com> wrote (in <eipts0dj403uus4ih7281mims11ao62g7i@4ax.com>) about
>'Is zero even or odd?', on Sun, 26 Dec 2004:
>>On Sun, 26 Dec 2004 06:57:26 GMT, vonroach <hadrainc@earthlink.net>
>>wrote:
>>
>>>On Fri, 24 Dec 2004 10:52:34 -0600, John Fields
>>><jfields@austininstruments.com> wrote:
>>>
>>>>Well... Not _really_, it's just a thought measurement.
>>>>---
>>>Careful, you are getting into Planck's range there.
>>
>>---
>>Careful? Why?
>>
>You may fall off the plank.
---
<G>roannnnnn...
--
John Fields
------------------------------
Date: Mon, 27 Dec 2004 08:21:25 -0600
From: John Fields <jfields@austininstruments.com>
Subject: Re: Is zero even or odd?
Message-Id: <2dvvs0ppsmtl1tgcpv4rp4fd8a5cko8bak@4ax.com>
On Mon, 27 Dec 2004 02:23:11 +0100, Michael Mendelsohn
<invalid@msgid.michael.mendelsohn.de> wrote:
>John Fields schrieb:
>> On Sat, 25 Dec 2004 00:23:49 +0100, Michael Mendelsohn
>> <invalid@msgid.michael.mendelsohn.de> wrote:
>> >John Fields schrieb:
>> >> ---
>> >> I'm not trying to be insulting, but would you mind explaining how the
>> >> current was measured?
>> >
>> >By putting an instrument into the circuit where I wanted to measure the
>> >current.
>>
>> ---
>> OK, but, unfortunately, placing the ammeter inside the short can only
>> give ambiguous results.
>
>That is my point exactly. A mathematical situation where you get 0/0 is
>ambiguous. If there is an unambiguous way to resolve it, you should have
>thought about it before. (See below).
---
Was that meant to be insulting?
---
>> >Presumbly that branch of the circuit had a box marked "resistor" in it,
>> >which should have contained a 100 Ohm resistor, so measured as if that
>> >had been there, but when I opened the box, I found it empty.
>>
>> ---
>> But, with the short in place, as you've shown it, it would be
>> impossible to determine whether the resistor was there or not, let
>> alone determining its value.
>
>Indeed, you got my point. You cannot determine if 0/0 should have a
>finite value, and even if, you can't determine what its value should be.
---
Yes, you can. I described how below.
---
>> >We're talking about hypothetical boxes and hypothetical resistors here,
>> >because I am trying to model a 0/0 quotient using an electrical circuit
>> >in the attempt show to Nicholas O. Lindan ("Nick" for short) that simply
>> >assuming that this quotient is 1 is a little reckless.
>
>> >> >> you would have measured the entire supply voltage minus what was being
>> >> >> dropped across the load by the current flowing through the meter and
>> >> >> you would have concluded that by subtracting the meter current that
>> >> >> you would have had:
>> >> >>
>> >> >> E E
>> >> >> R = --- = --- = oo
>> >> >> I 0
>> >> >>
>> >> >> Which would have been right!
>> >> >
>> >> >Unless E=0 too, in which case the result is 1 (says Nick).
>> >> >
>> >> >On a short circuit you can detect no voltage, but you can measure a
>> >> >current.
>> >> >
>> >> > E 0
>> >> > R = --- = --- = 0
>> >> > I I
>> >> >
>> >> >This leads to a contradiction when E=I=0.
>>
>> ---
>> I don't see why.
>
>
>Because E / 0 = oo and 0 / I = 0, in the case of E=I=0, both equations
>apply, and thus both results should be valid; but oo is not equal to 0.
---
When using Ohm's law:
E
R = ---
I
The assumption is made that in order for resistance to be measured, a
voltage and a current must exist. Implicit in that assumption is that
the voltage must be applied across, and the current forced to flow
through, the resistance.
Your circuit:
+---------------------(V)----+
| |
(-)-----o-------[__R__]---o---(A)----o--------(+)
|____________________________|
the short
contrives to hide the resistance while purporting to use Ohms law to
determine the resistance so, quite clearly, the results obtained will
be nonsensical.
The proper circuit:
+---(V)---+
| |
(-)---o---[R]---o---(A)---o---(+)
Will yield the proper results if examined using Ohm's law.
Assuming that the voltage across the resistance is 1V and the current
through it is 1A, then the resistance will be:
E 1V
R = --- = ---- = 1 ohm (1)
I 1A
If we now reduce the voltage to 0.5V and rearrange to solve for I,
we'll now have:
E 0.5V
I = --- = ------ = 0.5A (2)
R 1R
plugging that current into (1) gives us
0.5V
R = ------ = 1 ohm
0.5A
If we continue to reduce the voltage, the current and voltage will
always be numerically equal, R will remain at 1 ohm and, clearly, will
remain at 1 ohm even if we disconnect the voltage supply, forcing both
the voltmeter and ammeter to read 0, in which case we'll have:
0V
R = ---- = 1 ohm
0A
Now, if we go to the more general case of:
x
y = ---
x
we can see that for any value of x, as x goes to zero, y will remain
constant, and exactly equal to 1. Therefore,
0
--- = 1
0
---
>> Consider: Since
>>
>> x
>> y = --- = 1
>> x
>>
>> is certainly true for x = 1, x = 0.5, x = 0.25, and doesn't seem to
>> change as x diminishes toward, through and into the negative realm on
>> the other side of zero, why should there be an anomaly where x = 0?.
>
>Because you can't see from 0/0
>that it is the result of putting x=0 into x/x.
---
The value of x is unimportant. What does matter is that the numerator
and denominator be numerically equal.
---
>It might have been the result of putting 0 into 2x/x,
>in which case the result ought to be 2.
---
It might have been, but it wasn't.
---
>In fact, any c = cx/x = 0/0 for any c in R with x=0,
>so 0/0 could be any number c in R.
---
No. No matter how you arrive at zero being both the numerator and the
denominator, once it is the quotient _has_ to be 1.
---
>Only if you know that 0/0 came from x/x, you can say that it should be
>one;
---
Again, no. Where the zeroes came from is immaterial. If they're the
only terms or the only terms left standing in the numerator and the
denominator, the quiotient _must_ be 1.
---
>but if you know as much, why not eliminate the quotient when you
>initially see x/x?
---
That's not the point of the exercise. :)
---
>If you fear the division by zero, write code that does not divide by a
>variable. ;)
---
Right... Write code that multiplies by the reciprocal of the
variable instead?^)
--
John Fields
------------------------------
Date: Mon, 27 Dec 2004 09:49:45 -0500
From: Mike Kent <mkent@acm.org>
Subject: Re: Is zero even or odd?
Message-Id: <33alobF3ronllU1@individual.net>
John Fields wrote:
...
> x
> y = ---
> x
>
> we can see that for any value of x, as x goes to zero, y will remain
> constant, and exactly equal to 1. Therefore,
>
>
> 0
> --- = 1
> 0
5000 x
Likewise, if we consider y = --------
x
"we can see that for any value of x, as x goes to zero, y will
remain constant, and exactly equal to" 5000.
"Therefore,"
0
--- = 5000
0
and hence 1 = 5000.
------------------------------
Date: Mon, 27 Dec 2004 10:32:10 -0500
From: Gordon Weast <gweast@mathworks.com>
Subject: Re: Is zero even or odd?
Message-Id: <cqp9tq$i6o$1@fred.mathworks.com>
Nicholas O. Lindan wrote:
> "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com> wrote
>
>>>>j [sqrt(-1)] isn't a number but we still mix it up with numbers.
>>>
>>>Of course it is a number, thats why we treat it as such.
>>
>>Ok what it's value then?
>
>
> I'm still waiting for a jpeg of quantity sqrt(-1) apples.
> I confess my imagination does not stretch this far.
>
It's over here, right next to my picture of -1 apples...
That's even a real integer, equally as hard to picture.
------------------------------
Date: Mon, 27 Dec 2004 15:47:32 -0000
From: "George Dishman" <george@briar.demon.co.uk>
Subject: Re: Is zero even or odd?
Message-Id: <cqpaom$7rf$1@news.freedom2surf.net>
"John Fields" <jfields@austininstruments.com> wrote in message
news:2dvvs0ppsmtl1tgcpv4rp4fd8a5cko8bak@4ax.com...
> On Mon, 27 Dec 2004 02:23:11 +0100, Michael Mendelsohn
> <invalid@msgid.michael.mendelsohn.de> wrote:
>
<snip>
> When using Ohm's law:
>
> E
> R = ---
> I
>
> The assumption is made that in order for resistance to be measured, a
> voltage and a current must exist. Implicit in that assumption is that
> the voltage must be applied across, and the current forced to flow
> through, the resistance.
Correct so far.
> Your circuit:
>
>
> +---------------------(V)----+
> | |
> (-)-----o-------[__R__]---o---(A)----o--------(+)
> |____________________________|
> the short
>
> contrives to hide the resistance while purporting to use Ohms law to
> determine the resistance so, quite clearly, the results obtained will
> be nonsensical.
In the above circuit, the current measurement
is accurate but the voltage is the sum of that
across R and that across the ammeter. You must
subtract I times the resistance of the ammeter
from the voltage measurement to find the voltage
across the resistor.
> The proper circuit:
>
> +---(V)---+
> | |
> (-)---o---[R]---o---(A)---o---(+)
>
> Will yield the proper results if examined using Ohm's law.
In the above circuit, the voltage measurement
is accurate but the current is the sum of that
through R and that through the voltmeter. You
must subtract V divided by the resistance of
the voltmeter from the current measurement to
find the current through the resistor.
Neither circuit gives both readings accurately.
<snip proof that 1=1>
If you want to use an Ohms Law example to
understand this, realise that when you try to
calculate 0/0, you are asking "what resistance
will allow zero current to flow when zero voltage
is applied. The answer is any resistance. Equally,
you could ask what current flowing through a
superconductor produces zero volts and again the
answer is any current. Hence 0/0 can have any
value and it is therefore undefined.
George
------------------------------
Date: Mon, 27 Dec 2004 05:40:02 GMT
From: Don Shimoda <Donald.Shimoda@nospam.on.cox.net>
Subject: Re: need help in programming linux with perl
Message-Id: <SeNzd.3786$Y8.3369@newssvr17.news.prodigy.com>
Brian Wakem wrote:
> "Roll" <lie_huo@hotmail.com> wrote in message
> news:a0d432f2a1fe4711fc3029767b48e62f@localhost.talkaboutprogramming.com...
>
>>well i need to do a project and i was not allowed to use the webmin
>
> program
>
>>so do you haf any refrence that can teach me how to use perl to program
>>something like webmin?
>>
>
>
> You could download Webmin and look at the scripts that power it.
>
...since Webmin is written entirely in Perl. (To finish the sentence
and help the OP understand why this might be helpful.)
-ceo
------------------------------
Date: 27 Dec 2004 04:11:10 -0800
From: colin@beyondboxes.com
Subject: Pretty Printing (maybe with PDFs ?)
Message-Id: <1104149470.864599.54590@f14g2000cwb.googlegroups.com>
Hello, perhaps someone can help me. I'm in the process of updating some
in-house software written in Perl. The printing feature currently
prints out reports in tried-and-true monospaced ASCII text. I would
like to update this a tad, using some different fonts/styles and some
boxes/lines, maybe even add a little color such as our department's
.eps logo and a bitmapped graph or two. My first thought was to look
for a graphics generation library (like GD)... but at 600 dpi, that
would make for some huge page-sized bitmapped images! Then I thought
about hand rolling some Postscript. Now I'm thinking maybe PDF via some
sort of support module. Has anyone else trekked this route before? I'm
a PS and PDF newbie from the coding side of things! What do you
suggest? I'm leaning towards something that uses Postscript and/or PDF,
that way I can dump the generated file right to the printer and keep my
code as OS agnostic as possible.
Thanks in advance for any pointers!
------------------------------
Date: Mon, 27 Dec 2004 13:40:36 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Pretty Printing (maybe with PDFs ?)
Message-Id: <7l00t09qqsktrrpb758kj9n3q4sba8m00g@4ax.com>
On 27 Dec 2004 04:11:10 -0800, colin@beyondboxes.com wrote:
>Hello, perhaps someone can help me. I'm in the process of updating some
>in-house software written in Perl. The printing feature currently
>prints out reports in tried-and-true monospaced ASCII text. I would
>like to update this a tad, using some different fonts/styles and some
>boxes/lines, maybe even add a little color such as our department's
>.eps logo and a bitmapped graph or two. My first thought was to look
>for a graphics generation library (like GD)... but at 600 dpi, that
>would make for some huge page-sized bitmapped images! Then I thought
>about hand rolling some Postscript. Now I'm thinking maybe PDF via some
>sort of support module. Has anyone else trekked this route before? I'm
>a PS and PDF newbie from the coding side of things! What do you
>suggest? I'm leaning towards something that uses Postscript and/or PDF,
>that way I can dump the generated file right to the printer and keep my
>code as OS agnostic as possible.
What about using pdfLaTeX+listings.sty?!?
HTH,
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Mon, 27 Dec 2004 07:34:36 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Pretty Printing (maybe with PDFs ?)
Message-Id: <miTzd.11751$Tn1.315603@news20.bellglobal.com>
colin@beyondboxes.com wrote:
> Hello, perhaps someone can help me. I'm in the process of updating some
> in-house software written in Perl. The printing feature currently
> prints out reports in tried-and-true monospaced ASCII text. I would
> like to update this a tad, using some different fonts/styles and some
> boxes/lines, maybe even add a little color such as our department's
> .eps logo and a bitmapped graph or two. My first thought was to look
> for a graphics generation library (like GD)... but at 600 dpi, that
> would make for some huge page-sized bitmapped images! Then I thought
> about hand rolling some Postscript. Now I'm thinking maybe PDF via some
> sort of support module. Has anyone else trekked this route before? I'm
> a PS and PDF newbie from the coding side of things! What do you
> suggest? I'm leaning towards something that uses Postscript and/or PDF,
> that way I can dump the generated file right to the printer and keep my
> code as OS agnostic as possible.
>
> Thanks in advance for any pointers!
>
I use PDF::API2 for creating PDF in Perl. I recommend you download the
developer's version PDF-API2-0.40_77
If you need more help with it, subscribe to the mailing list:
http://groups.yahoo.com/group/perl-text-pdf-modules/
--- Shawn
------------------------------
Date: Mon, 27 Dec 2004 10:56:10 -0000
From: gbh <gbh04@tiscali.co.uk>
Subject: Re: retrieving Hash elements
Message-Id: <MPG.1c39faa0b7b19cc3989689@news.tiscali.co.uk>
In article <cqe7ai$ge9$4@mamenchi.zrz.TU-Berlin.DE>,
anno4000@lublin.zrz.tu-berlin.de says...
> George Kinley <georgekinley@hotmail.com> wrote in comp.lang.perl.misc:
> > daniel kaplan wrote:
> >
> > > Hello all,
> > >
> > > Was trying to see if there is a way to retrieve hash keys in the
> > > order they were created? Which I have not found in any of my books
> > > or perldoc. I realize I could make an array for the keys, and call
> > > it back that way, but I dunno, seems kind of kludge like.
> > >
> > > Thought there might be a simple way, but everything I read says "..do
> > > not have a guaranteed order."
> > >
> > > Thanks ahead,
> > >
> > > Daniel
> >
> > why not just add another key an index number and sort on index key
>
> Because it's inefficient. You *get* the keys in their desired sequence,
> so why use sorting to recover that sequence?
>
> Anno
>
If an integer is used as the key, or as prefix to the key, then "sort
bynumber" would be an option.
--
gbh
gbh04 is a spamtrap
all post is deleted
------------------------------
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:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#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 V10 Issue 7576
***************************************