[21882] in Perl-Users-Digest
Perl-Users Digest, Issue: 4086 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 8 14:07:46 2002
Date: Fri, 8 Nov 2002 11:05:08 -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 Fri, 8 Nov 2002 Volume: 10 Number: 4086
Today's topics:
Re: #!/usr/local/bin/perl (Helgi Briem)
Re: A vision for Parrot <usenet@dwall.fastmail.fm>
awstats logfile problem <oliver@email.ch>
Re: button groups <nobull@mail.com>
GUI with Perl ?? <mail@eircom.net>
Re: GUI with Perl ?? <tk@WINDOZEdigiserv.net>
Re: How to globally override a module function? <nobull@mail.com>
Re: Komodo Opinions (Jan Fure)
Re: Looking for directions : spawning independent CGIs <flavell@mail.cern.ch>
Re: Looking for directions : spawning independent CGIs <nobull@mail.com>
Re: Looking for directions : spawning independent CGIs <dglage_SPAMMERSWILLBEFLAMEDAT@gmx.de>
Memory Usage When Reading Large (non crlf) Files (CK)
Re: Object in @INC returning Tie::Handles from INC meth <nobull@mail.com>
Perl as a SPAM filter support@gethits22.com
Re: Perl as a SPAM filter <tk@WINDOZEdigiserv.net>
Re: Perl as a SPAM filter <twhu@lucent.com>
Re: script to modify database table as different user <pilsl_use@goldfisch.at>
Re: silent stack overflow in regex engine <wksmith@optonline.net>
Re: silent stack overflow in regex engine <edi@agharta.de>
Sort multidimensional hash? <user@server.com>
Re: Sort multidimensional hash? <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 08 Nov 2002 16:06:39 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: #!/usr/local/bin/perl
Message-Id: <3dcbe051.2033617126@news.cis.dfn.de>
On Fri, 8 Nov 2002 09:49:14 -0600, "Jerry Preston"
<g-preston1@ti.com> wrote:
>Hi!,
>
>Is it passable to have a script look at two different startup
>lines in ascript:
It is certainly passable, but is it possible?
>#!/usr/local/bin/perl
>#!/usr/bin/perl
>
>I have 20 servers with to many different locations for perl?
Have a look at perldoc perlrun.
You can trick it by using #!/usr/bin/env perl
A better way is to make a link from /usr/bin/perl and
/usr/local/bin/perl to the real one on all the machines.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Fri, 08 Nov 2002 18:45:21 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: A vision for Parrot
Message-Id: <Xns92C08BEEAB7F7dkwwashere@216.168.3.30>
Benjamin Goldberg <goldbb2@earthlink.net> wrote on 08 Nov 2002:
[lots of technical stuff]
Ack. My brain hurts. Make it stop....
--
David K. Wall - usenet@dwall.fastmail.fm
/me recalls the captured prisoners in Quake2
------------------------------
Date: Fri, 08 Nov 2002 16:41:40 GMT
From: Oliver Spiesshofer <oliver@email.ch>
Subject: awstats logfile problem
Message-Id: <8PRy9.49614$7j6.20527@fe03>
Hi,
I am running the latest version of awstats on a apache server.
the current months logfile is always called
domainname.com.access_log
however, each other days logfiles are called
dmoainname.com.access_log.01Nov2002.gz
and so on for each day.
how can I acces those?
thanks
Oliver
------------------------------
Date: 08 Nov 2002 17:01:13 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: button groups
Message-Id: <u9of903siu.fsf@wcl-l.bham.ac.uk>
"Jerry Preston" <g-preston1@ti.com> writes:
> I two sets of buttons in my script:
^^^
> group 1
>
> print $query->button( -name=>'SysFail',
> -value=>'Failed in System',
[snip]
> group 2
[snip]
> group 3
Huh?
> They inter react with each other.
In what way?
> Is it possible to have the buttons not react with each other?
That depends on what you are talking about.
The CGI button() method just creates an HTML <INPUT TYPE="SUBMIT" /> element.
It is very likely that whatever your question is it relates to HTML or
your web browser and not to Perl.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 8 Nov 2002 18:47:41 -0800
From: "Linux.ie" <mail@eircom.net>
Subject: GUI with Perl ??
Message-Id: <aqgt6e$ofs$1@dorito.esatclear.ie>
Is it possilbe to make GUI with perl on win98 ??
------------------------------
Date: Fri, 08 Nov 2002 18:57:22 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: GUI with Perl ??
Message-Id: <l82osu85gmfb1da3l1a955r7u0srhv64ua@4ax.com>
In a fit of excitement on Fri, 8 Nov 2002 18:47:41 -0800, "Linux.ie"
<mail@eircom.net> managed to scribble:
| Is it possilbe to make GUI with perl on win98 ??
|
If you've installed ActiveState Perl then it should already come with Tk
installed as a module.
Google'll help ya find out the syntax for Perl->Tk.
Regards,
tk
--
+--------------------------+
| digiServ Network |
| Web solutions |
| http://www.digiserv.net/ |
+--------------------------+
Remove WINDOZE to reply
------------------------------
Date: 08 Nov 2002 17:21:16 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to globally override a module function?
Message-Id: <u9d6pg3rlf.fsf@wcl-l.bham.ac.uk>
Phlip <phlipcpp@yahoo.com> writes:
> > *Test::Unit::Debug::debug = sub {
> > my ($package, $filename, $line) = caller();
> > print $out "***************************************that's the
> > facts, Jack!\n";
> > print $out @_ if $DEBUG{$package};
> > }
> > }
> >
> > That's as far as I can decipher the documentation on global hostile
> > takeover-style overrides. But even with "strict" and "-w" turned off,
> > Perl still screams at me: "Subroutine debug redefined..."
You can suppress that warning with:
no warnings 'redefine';
Note: switching off warnings globally and/or completely should usually be avoided.
BCP is to put "use warnings" at the top of every file. Switch off
unwanted warnings in the smallest enclosing lexical scope.
I still can't see why you'd be getting it with warnings switched off.
> > Then, if Perl think's it's "redefined" (past-tense), why don't Perl
> > then call it?
Hang on... could the two be related. What line number is appearing in
the "redefined" warning? Perhaps something is redefining it back again.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 8 Nov 2002 10:46:02 -0800
From: jan_may2002_fure@attbi.com (Jan Fure)
Subject: Re: Komodo Opinions
Message-Id: <e47a84bf.0211081046.22339cfa@posting.google.com>
"TBN" <ihave@noemail.com> wrote in message news:<xKuy9.2025$uwT2.36962367@news2.randori.com>...
> Does anyone have an opinion on what they like or dislike about Komodo as far
> as using Perl with it?
I have spent some time using a demo of kommodo, and what I found
lacking was the documentation.
My reasoning for using kommodo was to utilize the GUI builder, but
there was no examples on how to tie together the Perl script and the
GUI functionality, the GUI builder was simply described as a stand
alone CAD tool to construct windows. The WIN32::GUI module is way
better documented.
Jan
------------------------------
Date: Fri, 8 Nov 2002 16:45:44 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Looking for directions : spawning independent CGIs
Message-Id: <Pine.LNX.4.40.0211081625390.3267-100000@lxplus074.cern.ch>
On Nov 8, Ole Voss inscribed on the eternal scroll:
> I want to do some database administration using a web-interface.
> Once the file is uploaded the Perl script has a lot of work to do. Because
> the browser doesn't wait long enough for the script to finish, but rather
> reports a server error (after approx. 5 min) I would like to seperate the
> tasks from one another.
Standard CGI FAQ, but nothing specific to Perl.
E.g http://www.htmlhelp.com/faq/cgifaq.3.html#8
(note that the immediately following FAQ isn't really the answer to
your question, since you don't need to interact continuously with the
long-running process).
> My Idea was to spawn a child process and keep the browser busy reloading a
> dynamically created html-page.
You want that the user should do nothing else in their browser window
for > 5 minutes waiting for a response to say the process is complete?
That might not be optimal...?
> Unfortunately it seems that it's not possible
> since the execution of the perl script is bound to the http-server-user and
> process.
Not quite sure which part of the problem you're referring to here.
Launching the job (in a way that avoids it getting killed by the web
server) is what the above FAQ addresses. Keep in mind that the CGI
script model is for the client to invoke a URL, which causes the
server to do a modest amount of processing without undue delay, return
an answer, and that's the end of that particular HTTP transaction.
If that was only the launching of a long-running process, then you may
want some way to visit later and review the progress of the request,
which I presume is the point of your question.
Since HTTP itself is stateless. that needs some way of "maintaining
state", for which there are plenty of tutorials.
Alternatively the invoker could identify themselves by email address,
and the long-running process could announce completion by emailing the
results. (Please implement this in a way that avoids it being misused
as an open spam-relay.)
> Any ideas?
Read FAQs, and pitch your questions, on the more-appropriate group[1],
by reference to a specific FAQ that you haven't understood. Usually
brings better results.
[1]comp.infosystems.www.authoring.cgi - read its posting guidelines
------------------------------
Date: 08 Nov 2002 17:03:03 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Looking for directions : spawning independent CGIs
Message-Id: <u9lm443sfs.fsf@wcl-l.bham.ac.uk>
"Ole Voss" <ole.voss@netrogue.de> writes:
> My Idea was to spawn a child process and keep the browser busy reloading a
> dynamically created html-page. Unfortunately it seems that it's not possible
> since the execution of the perl script is bound to the http-server-user and
> process.
Cut the ties that bind! (i.e. the close or repopen the STD*
file handles).
> Any ideas?
BTW: This has nothing to do with Perl - you'd do the same in a CGI
written in any language.
BTW: This is in the Perl FAQ nonetheless - but it's not easy to find
because it appears as "How do I fork a daemon process?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 8 Nov 2002 19:19:29 +0100
From: Daniel Glage <dglage_SPAMMERSWILLBEFLAMEDAT@gmx.de>
Subject: Re: Looking for directions : spawning independent CGIs
Message-Id: <Xns92BFC2C3A15EFNowstopsanobleheartG@62.153.159.134>
"Ole Voss" <ole.voss@netrogue.de> wrote in
news:aqggp5$9t88l$1@ID-118921.news.dfncis.de:
> Because the browser doesn't wait long enough for the script to finish,
> but rather reports a server error (after approx. 5 min) I would like
> to seperate the tasks from one another.
It WILL however wait, if you forcibly keep the connection up. Why not send
a HTML comment every now and then during the process?
Anyways... the other answers I've seen so far should provide what you are
looking for.
You might want to consider following up to another newsgroup though. :-)
------------------------------
Date: 8 Nov 2002 10:39:13 -0800
From: fw58959@hotmail.com (CK)
Subject: Memory Usage When Reading Large (non crlf) Files
Message-Id: <c0367340.0211081039.1323f60d@posting.google.com>
Hello,
I have large log files (~300MB each x 4-5 per day) which are stored in
binary format. These log files are one continuous stream of data
which is composed of records of about 1500 bytes in length. These
records are further composed of smaller subrecords of about 50 bytes
(so ~30 sub records per record). I decode by reading 'x' number of
bytes at a time and moving along the file. A snippet
of the code follows:
$hdr5_len = 25;
$data5_len = 48;
$hdr7_len = 25;
$data7_len = 52;
$version_length = 2;
$offset = 0;
while (read(IN,$buffer,$version_length)) {
$version = unpack("s",$buffer);
if ($version == 5) {
$offset = $offset+$version_length;
$hdr_len = 24-$version_length;
$data_len = 48;
}
elsif ($version == 7) {
$offset = offset+$version_length;
$hdr_len = 24-version_length;
$data_len = 52;
}
else {
die "Program not designed to handle version $version records\n";
}
read(IN,$hdr,$hdr_len); # Start reading header of record
($count,$rtruptime,$timesec,$timensec,$flowseq,$PAD1) =
unpack("sIIIIc5",$hdr);
$offset = $offset+$hdr_len;
for (1..$count) { # decode each subrecord and print it to another
file
read(IN,$data,$data_len);
....unpack the data into variables....
....print the variables to a file (essentially making a human
readable file) - one crlf record of data for each subrecord
$offset = $offset + $data_len;
}
}
I hope the formatting doesn't make it difficult to read. I also
removed the guts of the program to show the basic structure and flow.
The problem I am having is that I keep running out of memory. When I
run it on a 4GB box no problem as I have enough memory but I recently
put it on a 256MB box and most of the time trying to run the program
fails because of memory. On the 4GB machine memory climbs quite high
but I have enough there to do the job. It seems to me that I
shouldn't
need that much memory to decode 1500 bytes at a time.
Is there a better way to do this?
Thanks.
./CK
------------------------------
Date: 08 Nov 2002 18:36:05 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Object in @INC returning Tie::Handles from INC method
Message-Id: <u97kfn52p6.fsf@wcl-l.bham.ac.uk>
rook_5150@yahoo.com (Bryan Castillo) writes:
> sub new {
> print "Making a new one\n";
> my $class = shift;
> my $self = gensym();
> return tie *{$self}, $class, $self, @_;
> }
>
> sub TIEHANDLE {
> print "lets tie it\n";
> my ($class, $self, $member) = @_;
> bless $self, $class;
> ${*$self}{member} = $member;
> ${*$self}{buffer} = '';
> return $self;
> }
I've not played with 5.8's new @INC but making a tied filehandle where
the object to which it is tied is the GLOB _itself_ seems unecessarily
convoluted. Perhaps this is confusing Perl. Perhaps it isn't. But
it certainly confused me!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 08 Nov 2002 17:14:14 GMT
From: support@gethits22.com
Subject: Perl as a SPAM filter
Message-Id: <3DCBF204.5030701@gethits22.com>
Spam is getting so bad it's beginning to have a
significant effect the bottom line of my business.
I'm looking for a server-side perl spam solution
for my business...I'm interested in anyone's
experience with either ActiveState's commercial
product or Mail::Audit and Mail::SpamAssassin.
Thanks,
Darryl
------------------------------
Date: Fri, 08 Nov 2002 17:21:35 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Perl as a SPAM filter
Message-Id: <vjsnsuga9hf7cs5du7ahclv5769mumb7sh@4ax.com>
In a fit of excitement on Fri, 08 Nov 2002 17:14:14 GMT,
support@gethits22.com managed to scribble:
| Spam is getting so bad it's beginning to have a
| significant effect the bottom line of my business.
|
| I'm looking for a server-side perl spam solution
| for my business...I'm interested in anyone's
| experience with either ActiveState's commercial
| product or Mail::Audit and Mail::SpamAssassin.
|
| Thanks,
| Darryl
As an alternative, could this not be "better" performed at the actual
server itself?
I run Postfix on my server and use RegEx header and body checking for
spam blockage. It'll depend on what you want to do with it I guess,
either block outright, or mark as spam but allow through.
Regards,
tk
--
+--------------------------+
| digiServ Network |
| Web solutions |
| http://www.digiserv.net/ |
+--------------------------+
Remove WINDOZE to reply
------------------------------
Date: Fri, 8 Nov 2002 12:41:34 -0500
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: Perl as a SPAM filter
Message-Id: <aqgt0m$ihe@netnews.proxy.lucent.com>
I'm using Mail::Audit to filter out unwanted emails and
I like it. The logfile shows that there are about 10-20
unwanted email messages per day. I need to preserve
some my friends emails. I filter out all Korean characters
email messages because I cannot read them anyway. I
foward the unwanted email messages to our security
department and hopefully the unwanted email addresses
will be added to the list of the company mail server.
<support@gethits22.com> wrote in ...
> Spam is getting so bad it's beginning to have a
> significant effect the bottom line of my business.
>
> I'm looking for a server-side perl spam solution
> for my business...I'm interested in anyone's
> experience with either ActiveState's commercial
> product or Mail::Audit and Mail::SpamAssassin.
>
> Thanks,
> Darryl
------------------------------
Date: Fri, 8 Nov 2002 18:47:01 +0100
From: peter pilsl <pilsl_use@goldfisch.at>
Subject: Re: script to modify database table as different user
Message-Id: <3dcbf8ca$1@e-post.inode.at>
Andrew wrote:
>>
> good point. i know others have mentioned a "wrapper" binary to me. i
> know how to write a cgi script which could do what you say, but how do i
> restrict
> access to the script in apache? .htaccess still passes the password in
> clear text.
>
apache has nothing to do with it. I just compared the situation.
Your request was to have a script that can alter certain parts of a
sql-database but the calling user should never have the opportunity to
change anything else in this database or sniff the password.
So you write a small server in perl that runs under a different account and
has the sql-databases in plaintext and establish the connection to the
sql-server.
The client (also a perlscript) is accessible by the user and sends the
userdata to the perl-server.
Of course you can also use a websolution. You can use htaccess then, cause
the passwords used with htaccess can be completely different to the
sql-databases. Apache runs under a different account also, so the user cant
sniff the passwords.
>
> can you provide any links with more information you idea? how do i bind
> the
> script to a different port? i have a web server running apache on port 80
> already.
>
man perlipc
you dont need to listen your sript on port 80. It has nothing to do with
apache. If you want to use apache, you just write a cgi that connects to
the sql-database and restrict access to this script with wellknown
apache-methods.
best,
peter
--
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Fri, 08 Nov 2002 17:32:11 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: silent stack overflow in regex engine
Message-Id: <vySy9.2761$XG3.2485@news4.srv.hcvlny.cv.net>
"Edi Weitz" <edi@agharta.de> wrote in message
news:87znslx9gg.fsf@bird.agharta.de...
> edi@bird:~ > perl -le '$_="x" . ("a" x (2 ** 15 - 1)) . "y"; print
(/x(bc|a)*y/ ? "yes" : "no");'
> yes
> edi@bird:~ > perl -le '$_="x" . ("a" x (2 ** 15)) . "y"; print
(/x(bc|a)*y/ ? "yes" : "no");'
> no
>
> I've seen this with Perl 5.005, 5.6.0, 5.6.1, and 5.8.0 on various
> Linux 2.4.x machines and on FreeBSD 4.5. With Linux 2.2.x and Solaris
> 5.8 (both Perl 5.6.1) I got core dumps instead. (I think I like the
> core dumps a little bit more. At least I'm not getting a wrong
> result... :)
>
> Is this a known bug or should I report it somewhere?
>
> Thanks,
> Edi.
I ran both in a perl script with use strict and use warnings under 5.6.1.
Both reported the warning
"Complex regular expression recursion limit (32766) exceeded at ...."
Sounds like a known limit to me.
Bill
------------------------------
Date: 08 Nov 2002 19:08:56 +0100
From: Edi Weitz <edi@agharta.de>
Subject: Re: silent stack overflow in regex engine
Message-Id: <878z049bnr.fsf@bird.agharta.de>
"Bill Smith" <wksmith@optonline.net> writes:
> "Edi Weitz" <edi@agharta.de> wrote in message
> news:87znslx9gg.fsf@bird.agharta.de...
> > edi@bird:~ > perl -le '$_="x" . ("a" x (2 ** 15 - 1)) . "y"; print
> (/x(bc|a)*y/ ? "yes" : "no");'
> > yes
> > edi@bird:~ > perl -le '$_="x" . ("a" x (2 ** 15)) . "y"; print
> (/x(bc|a)*y/ ? "yes" : "no");'
> > no
> >
> > I've seen this with Perl 5.005, 5.6.0, 5.6.1, and 5.8.0 on various
> > Linux 2.4.x machines and on FreeBSD 4.5. With Linux 2.2.x and Solaris
> > 5.8 (both Perl 5.6.1) I got core dumps instead. (I think I like the
> > core dumps a little bit more. At least I'm not getting a wrong
> > result... :)
> >
> > Is this a known bug or should I report it somewhere?
> >
> > Thanks,
> > Edi.
>
> I ran both in a perl script with use strict and use warnings under 5.6.1.
> Both reported the warning
> "Complex regular expression recursion limit (32766) exceeded at ...."
>
> Sounds like a known limit to me.
> Bill
Thanks, I always forget 'use strict' and 'use warnings'... :)
However, on my machine (Perl 5.6.1) 'use strict' alone doesn't suffice
to get the warning, you need to say 'use warnings'.
Cheers,
Edi.
------------------------------
Date: Fri, 08 Nov 2002 16:24:43 GMT
From: T Stephens <user@server.com>
Subject: Sort multidimensional hash?
Message-Id: <Xns92C055922F91Dtimstephens@24.69.255.211>
I need to sort a multidimensional hash by values, but I can't seem to
wrap my head around this. I have sorted hashes by value before, but
haven't needed to work with multidimensional ones before.
For example, if I have the following data:
Name Games Goals Assists Points
Mario 12 8 21 29
Martin 13 9 11 20
Alex 13 8 11 19
Mike 14 8 10 18
I was planning on setting up the hash structure like so (although it
would be loading in from a datafile, and would be looped over):
$hash{1}{name} = "Mario";
$hash{1}{games} = 12;
$hash{1}{goals} = 8;
$hash{1}{assists} = 21;
$hash{1}{points} = 29;
$hash{2}{name} = "Martin";
$hash{2}{games} = 13;
$hash{2}{goals} = 9;
$hash{2}{assists} = 11;
$hash{2}{points} = 20;
(and so on)
Then I need to be able to generate outputs where the data is sorted
alphabetically based on almost any criteria and keep the other stats with
the corresponding player. Obviously, there would be no point in showing
Mario's name with Mike's games, Martin's assists, and Alex's points.
I also need to be able to sort the data based on games, goals, assists,
and points.
I've scoured over my Perl books and they do cover sorting hashes on
values and multidimensional arrays, but never at the same time.
Any assistance would be greatly appreciated. Perhaps I'm going about this
all wrong...if so let me know that too.
Tim
------------------------------
Date: 08 Nov 2002 17:14:54 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Sort multidimensional hash?
Message-Id: <u9fzuc3rv7.fsf@wcl-l.bham.ac.uk>
T Stephens <user@server.com> writes:
> I need to sort a multidimensional hash by values, but I can't seem to
> wrap my head around this. I have sorted hashes by value before, but
> haven't needed to work with multidimensional ones before.
>
> For example, if I have the following data:
>
> Name Games Goals Assists Points
> Mario 12 8 21 29
> Martin 13 9 11 20
> Alex 13 8 11 19
> Mike 14 8 10 18
>
> I was planning on setting up the hash structure like so (although it
> would be loading in from a datafile, and would be looped over):
>
> $hash{1}{name} = "Mario";
> $hash{1}{games} = 12;
> $hash{1}{goals} = 8;
> $hash{1}{assists} = 21;
> $hash{1}{points} = 29;
> $hash{2}{name} = "Martin";
> $hash{2}{games} = 13;
> $hash{2}{goals} = 9;
> $hash{2}{assists} = 11;
> $hash{2}{points} = 20;
> (and so on)
If the first level subscripts contain to meaning or are always
successive natural numbers it's probably better to subtract one and
use an array. Always try to use the natural tool for the job.
> Then I need to be able to generate outputs where the data is sorted
> alphabetically based on almost any criteria and keep the other stats with
> the corresponding player. Obviously, there would be no point in showing
> Mario's name with Mike's games, Martin's assists, and Alex's
> points.
my @sorted = sort { $a->{name} cmp $b->{name} } values %hash;
Or, if you follow my advice above:
my @sorted = sort { $a->{name} cmp $b->{name} } values @array;
> I also need to be able to sort the data based on games, goals, assists,
> and points.
my @sorted = do {
if ( $numerically ) {
sort { $a->{$sortkey} <=> $b->{$sortkey} } values @array;
} else {
sort { $a->{$sortkey} cmp $b->{$sortkey} } values @array;
}
};
> I've scoured over my Perl books and they do cover sorting hashes on
> values and multidimensional arrays, but never at the same time.
Being able to combine two trivial operations together is an important
skill.
comp.lang.perl does not exist. Please do not start threads there.
See FAQ.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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.
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 4086
***************************************