[11549] in Perl-Users-Digest
Perl-Users Digest, Issue: 5149 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 16 15:07:30 1999
Date: Tue, 16 Mar 99 12:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 16 Mar 1999 Volume: 8 Number: 5149
Today's topics:
Re: 1000 thread limit? archon16@my-dejanews.com
Re: 2d-array sort (Larry Rosler)
ACTIVE PERL CGI ON WINNT 4.0 vtomchal@my-dejanews.com
Re: Are negative array indeces allowed? (brian d foy)
Re: Array-Sort (Larry Rosler)
Re: Detecting a whitespace at the end of a string <cassell@mail.cor.epa.gov>
Re: Hash of structs <jglascoe@giss.nasa.gov>
RE: Help with perl ppp dialer (SANTOS JASON M)
Inheriting question, please help :) <please_reply@newsgroup.com>
Re: localtime, timelocal <droby@copyright.com>
Re: Newbie question... <sethd@sethd.com>
Re: Newby Question <jglascoe@giss.nasa.gov>
NT 4.0 Server Problems with CGI vtomchal@my-dejanews.com
Problem with NetResource ... or is it me? <kevin.lund@westgroup.com>
Re: Real Funny Browser/CGI Behavior (brian d foy)
Re: Regex $1 behavior (Larry Rosler)
Re: Regex limits for regex/function calls within subsit <jhi@alpha.hut.fi>
Re: Regex limits for regex/function calls within subsit (Tad McClellan)
Re: Regex limits for regex/function calls within subsit <burton.not.spam@lucent.com>
Re: Slurping multiple files as input <jglascoe@giss.nasa.gov>
Re: Sorting Problem (Sami Rosenblad)
Sorting with Perl <alain_chiorboli@email.sps.mot.com>
Re: Sorting with Perl (brian d foy)
symbolic method references? <ekkis@arix.com>
Re: The truth about the Pentium III chip and ID --- **b <banderson@boi.hp.com>
Re: Unable to find load file LS <cassell@mail.cor.epa.gov>
Re: Web Programming (brian d foy)
Re: Which is better for Windows use: perl or python <cassell@mail.cor.epa.gov>
which version of perl5/lwp should we be using? (Michael Budash)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 Mar 1999 19:01:51 GMT
From: archon16@my-dejanews.com
Subject: Re: 1000 thread limit?
Message-Id: <7cm9qn$ldt$1@nnrp1.dejanews.com>
First of all, I'd like to thank you, Dan, for giving me your excellent
responses. You've given me much food for thought and sent me researching
thread pools and such. I think I might be able to actually pull this off
after all! Read on...
In article <7chb6g$60e$1@news.NERO.NET>,
Dan Sugalski <sugalskd@netserve.ous.edu> wrote:
> Using a thread pool would make scaling easier in some ways--set up a queue
> that holds the connection info (pouring more into it if need be) and then
> create a boatload of threads that each snag a record out of the queue and
> Do The Right Thing with it. (Which may well be the approach you're
> considering)
I don't know much about thread pooling, but... is this what you had in mind?
use Thread::Pool;
sub doStuff($) {
# do some ... uh ... stuff.
}
my $pool = Thread::Pool->new(Max => -1);
foreach $address (@addresses) {
$pool->enqueue(\&doStuff, $address);
}
Note that I set Max to -1, which supposedly means no limit on the pool size;
will the Thread::Pool module then be smart enough to automatically detect the
OS thread limit and stay just under it?
Aside from that, my main concern with this method would be the overhead
associated with creating and destroying millions of threads, potentially
several thousand each second. Whereas if I manage my own pool manually, I
can re-use the same thread for multiple connections. I can just have a
static pool of 30K or so threads, such that each thread grabs pending
addresses from a common pool and processes them in serial:
use Thread;
sub doStuff() {
while ($addr = getNextAvailableAddress()) { # Use this one thread for
# do some stuff thousands of addresses!
}
}
while ($t = new Thread(\&doStuff)) {
push @pool, $t;
}
foreach $t (@pool) { $t->join() }
(I can't think of any simple way to do this using Thread::Pool.) Which method
do you think is better? Is the thread creation/destruction overhead really
significant, or am I just complicating things trying to avoid it?
> Just out of curiosity, how much longer does it take with
> 1000 threads vs your current 30K version? (It's always possible that it
> just doesn't matter, since you're bottlenecking other places)
About thirty times longer. There is no bandwidth bottleneck, because the
vast majority of connection attempts fail (like, 99.9%), so the only
bottleneck is OS resources!
Well, at any rate ... a friend of mine is going to build his own web server
and put it on an OC-3 connection (155Mbps). I'm going to help him build the
machine and choose an OS and software, etc, and I'll have free reign to run
my program, but I don't want to hog all his system resources! So now I have
all sorts of options! :-) What OS should we choose, how do we configure
mondo-thread capability, and how do I make my program play nice?
Thanks for all your help so far!
- Archon
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 13 Mar 1999 08:09:12 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 2d-array sort
Message-Id: <MPG.11542d808f47fff7989737@nntp.hpl.hp.com>
In article <7cdni1$f4k$1@nnrp1.dejanews.com> on Sat, 13 Mar 1999
13:00:52 GMT, Stefan@Stark.net <Stefan@Stark.net >says...
...
> I have an array which looks like this: @Data1 = ( ( "1", "Hans", "Hamburg" ),
> ( "5", "Maria", "Mainz" ), ("2", "Fred", "Frankfurt" ) );
Well, at least when you posted this question the second time (from a
different place), you put quotes around the bareword.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 16 Mar 1999 18:28:30 GMT
From: vtomchal@my-dejanews.com
Subject: ACTIVE PERL CGI ON WINNT 4.0
Message-Id: <7cm7ru$jh2$1@nnrp1.dejanews.com>
I have a simple perl script that i am trying to run on a WINNT 4.0 Server.
When the html page attempts to activate the script, I get the following
message:
HTTP 1.0 501 Not Supported
I even did another test with a simple server side batchfile and got the same
message. Do you have any ideas what the problem may be? Perhaps an
environment variable needs to be set at the server side?
I am running Active Perl on the server, and the /perl/bin directory is in
the path. But the batchfile is really the clincher for me that at this point
the problem is non-Perl related.
Any input would be greatly appreciated.
Regards,
Vance Tomchalk
Altera Corporation
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Mar 1999 14:31:22 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Are negative array indeces allowed?
Message-Id: <comdog-ya02408000R1603991431220001@news.panix.com>
In article <36EE96C8.5735F5AD@gte.com>, jc@eddie.mit.edu posted:
> Hmmm .. You're probably right. But I'd still say, on re-reading Alex's
> question, that the answer to the question that he was asking is "No".
> That is, perl does accept negative numbers as array indexes, but perl
> doesn't implement negative array indexes.
sure it does, just not in the number line idea that you have in
your head. not only only are they implemented, but they are defined
and documented along with being idiomatic.
> It does something *very*
> different with a negative index than would be expected by anyone who
> uses the phrase "negative array index".
anyone? maybe you meant "me".
> A programmer who notices the
> use of a negative number as an index, thinks "Oh, negative indexes now
> work" and writes code to use them is in for a rather nasty surprise.
this can be said for any feature for which the unsuspecting
programmer does not read the documentation.
> (Of course, we could just post a large warning: "Perl may be dangerous
> to the mental health of people with any mathematical background. RTFM
> with great care before use." ;-)
it depends which algebra you are talking about. Perl behavior with
negative numbers used as array indices seems to make perfect sense
from a group theoretical perspective, even though the indices are
not cyclic. Perl's behaviour in this regard never seemed exotic
to me, but maybe because that's due to too much math in my background ;)
remember that mathematics is about rules. set up some rules that
are consistent then work within rules. that is what Perl (or any
other language) does (mostly). you just need to know the rules.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 13 Mar 1999 07:43:57 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Array-Sort
Message-Id: <MPG.1154278f98c518ee989735@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36ea72ec.14380578@news.uni-ulm.de> on Sat, 13 Mar 1999
14:20:45 GMT, Hans-Georg Rist <hans-georg@rist.net >says...
...
> @data = ( [ "1", "Hans", "Hamburg" ],
> [ "5", "Maria", "Mainz" ],
> [ "2", "Frank", "Frankfurt" ]
> );
...
> # use the Schwartzian Transform for sorting:
>
> @data2 = map { $_->[0] }
> sort { $a->[1] <=> $b->[1] } # numerically
> map { [ $_, $_->[0] ] }
> @data;
Overkill alert! The data are already sortable.
@data2 = sort { $a->[0] <=> $b->[0] } # numerically
@data;
I posted a similar solution moments before yours appeared here, and was
amused to realize that in essence the ST was already done.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 16 Mar 1999 11:12:01 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Detecting a whitespace at the end of a string
Message-Id: <36EEAD01.45D5993A@mail.cor.epa.gov>
Alex Farber wrote:
> kate_stafford@my-dejanews.com wrote:
> > Users"). The program that is generating the group names sticks a whitespace
> > or sometimes 2 at the end of the string that I wish to chop. I came up with
> > the following until loop:
> >
> > until ($group =~ /^[A-Za-z][_0=9a-zA-Z]*$\b/)
> > {
> > chop $group;
> > }
> >
>
> Kate,
> maybe I've completely misunderstood your problem, but why don't you
> $group =~ s/\s+\n//;
> Or if you have several groups on a line
>
> @groups = split ' ', $group;
>
> Regards
> /Alex
Umm.. I would write Alex's first suggestion as:
$group =~ s/\s+$//;
Of course, if you know that the problem is always 'one or two whitespaces'
at the end, you could write it as:
$group =~ s/\s{1,2}$//;
HTH,
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 16 Mar 1999 14:17:52 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Prem Gangalakunta <pgangala@i2.com>
Subject: Re: Hash of structs
Message-Id: <36EEAE60.E5EC7420@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Prem Gangalakunta wrote:
>
> I am trying to use a H0H (Hashes of Hashes) where each element is a structure(array) of two
> elements.
>
> I was expecting the following statement to push the array of 2 fields into HoH
> push(
> @HoH{$fields[$idx_date]}{$fields[$idx_model_size]},
> ($fields[$idx_duration], $fields[idx_process_size])
> );
push @{ $HoH{$outer_key}{$inner_key} }, $first_thing, $second_thing;
> The Error encountered is:
<snip>
yeah, "@hash{foo, bar}" evaluates to a list "($hash{foo}, $hash{bar})",
aka a "hash slice". So, "@HoH{$outer_key}" is a singleton list of
one of your inner hashes.
Jay Glascoe
--
"Just say 'Narf!'"
--Pinky
------------------------------
Date: Tue, 16 Mar 1999 11:01:17 -0700
From: jmsantos@srpnet.com (SANTOS JASON M)
Subject: RE: Help with perl ppp dialer
Message-Id: <037164847588D111B5D600600858CDD604DA9823@srp.gov>
[snip]
ogin: dbohling
assword: tristan);
^^^^^^^^^^^^^^^^^^
You might want to consider changing your PPP dial in password, now that
you've posted it for all the world to see.....
--
Jason M. Santos - Unix Sysadmin - Alternative Resources Corp
Currently consulting: Salt River Project - Phoenix, AZ USA
em: jmsantos@srpnet.com ph: +1 602 236 5155
PGP FP: CFFA C31D 8D95 8BF3 1D1A A5EB FC52 4117 27FB A6B0
------------------------------
Date: Tue, 16 Mar 1999 13:22:21 -0600
From: "Don Pritchard" <please_reply@newsgroup.com>
Subject: Inheriting question, please help :)
Message-Id: <7cmb9q$cee@dfw-ixnews11.ix.netcom.com>
If I have a ksh script, which calls a perl script, which calls a ksh script
(via the "`" method). Will the final ksh script have available to it any
Unix environment variables set in the first script?
Thanks
------------------------------
Date: Tue, 16 Mar 1999 17:48:43 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: localtime, timelocal
Message-Id: <7cm5hn$h71$1@nnrp1.dejanews.com>
In article <7clssb$8ic$1@nnrp1.dejanews.com>,
nouksopha@hotmail.com wrote:
> #!/usr/bin/perl -w
> #!/usr/local/bin/perl -w
> #!/usr/local/perf/bin/perl -w
> use Time::Local;
>
> print localtime, "\n";
> print $mytime = timelocal(00,01,02,01,03,99,0,0,0), "\n";
> print localtime($mytime), "\n";
> print $mytime = timelocal(00,01,02,29,02,99,0,0,0), "\n";
> print localtime($mytime), "\n";
>
> __END__
> this is the result i got. (on AIX 4)
> 11479162992740
> 922953660
> 01213994900
> 922694460
> 012292991870
>
> What is wrong with the code above? should the result be the same since there
> is no 2/29/99 date? Is this a bug in perl? I coded this in C using C
> library mktime() and localtime() and it works just fine.
>
The month index in localtime and timelocal starts from 0. Your program is
comparing March 29 with April 1, which are indeed distinct and legitimate
dates.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Mar 1999 18:02:29 GMT
From: "Seth Davis" <sethd@sethd.com>
Subject: Re: Newbie question...
Message-Id: <V0xH2.4714$NO2.525241@news1.usit.net>
Thanks! :)
------------------------------
Date: Tue, 16 Mar 1999 14:34:46 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: mojo@trianglenet.net
Subject: Re: Newby Question
Message-Id: <36EEB256.C9CF68B8@giss.nasa.gov>
[posted and mailed]
Ramona wrote:
>
> Hello,
<snip>
> print
> "<Content-Type: text/html\r\n\r\n";
^
|
That '<' shouldn't be there. Also, I don't think you need
those carriage returns, '\r'.
> print "<html>\n";
> print "<head>\n";
<snip>
> print "</body> \n";
> print "</html>\n";
A "here doc" may be more appropriate than many separate
print statements:
print << "EOF";
<html>
<head><title>Narf!</title></head>
<body>
Your Add Here...
</body>
</html>
EOF
Jay Glascoe
--
Poit!
------------------------------
Date: Tue, 16 Mar 1999 18:43:42 GMT
From: vtomchal@my-dejanews.com
Subject: NT 4.0 Server Problems with CGI
Message-Id: <7cm8os$k8f$1@nnrp1.dejanews.com>
I have an NT 4.0 Server with Active Perl. I am having problems running a
simple perl CGI script and a simple NT batch CGI script from an HTML page. I
get the following error message:
HTTP 1.0 / 501 Not Supported
Is there something else that I need to be running at the server end, in order
for even a simple CGI batch file to be executed.
Any input would be greatly appreciated.
Regards,
Vance Tomchalk
vtomchal@altera.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Mar 1999 12:47:51 -0600
From: "Kevin Lund" <kevin.lund@westgroup.com>
Subject: Problem with NetResource ... or is it me?
Message-Id: <36eea64f@wwwproxy3.westgroup.com>
I've been getting this lovely error:
===============
D:\perl>perl scripts\drivetst.pl
Can't load 'D:\PERL\site\lib/auto/Win32/NetResource/NetResource.dll' for
module Win32::NetResource: load_file:A device attached to the system is not
functioning at D:\PERL\lib/DynaLoader.pm line 168.
at scripts\drivetst.pl line 15
BEGIN failed--compilation aborted at scripts\drivetst.pl line 15.
===============
while attempting to run a very simple test script I wrote. I was able to do
a test using the Win32::File module, so it doesn't seem that my whole system
is screwed up.
I'm leaning towards blaming myself for this one, because I "accidentally"
installed Win32-NetResource using PPM when I already had Win32::NetResource
with the basic ActiveState distribution. After playing around a few times
with installing/uninstalling the package and deleting files, I decided to do
a complete un-install of ActiveState Perl and then re-install fresh.
Alas, the NetResource still fails, while the File still works. I searched
FAQ's and DejaNews but found nothing that seemed to be relevant. Has anyone
seen this before who could explain what I managed to do to render myself
NetResource impotent?
Thanks in advance,
Kevin Lund
------------------------------
Date: Tue, 16 Mar 1999 14:33:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Real Funny Browser/CGI Behavior
Message-Id: <comdog-ya02408000R1603991433140001@news.panix.com>
In article <7clt5n$8uh$1@nnrp1.dejanews.com>, tatabu@my-dejanews.com posted:
> I am trying to use the line of code
>
> $sizes=imgsize("friend.jpg");
>
> in a CGI script file. When I call that cgi file with any one of the
> three browsers (Netscape, MSIE, Opera), I get an error.
should we guess what the error is, or are you going to give us a hint? ;)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 13 Mar 1999 07:59:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regex $1 behavior
Message-Id: <MPG.11542b444dd81d33989736@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36E99C46.418D20BE@idt.net> on Fri, 12 Mar 1999 17:59:18 -
0500, James Tolley <jamesht@idt.net >says...
> You can use $1 outside the regex operation, but you should use \1 within it:
Wrong! Use \1 only *within the regex itself*. The 'regex operation' (I
guess you mean the substitution part of the operation) should use $1.
> #!/usr/bin/perl -w
>
> 3:$address = "127.0.0.1";
> 4:$address =~ s/((\d+\.)*)/\1/; # NOT '$1'
This draws a warning:
\1 better written as $1 at ...
> 5:print $address, "\n"; # eq "127.0.0.1" <- I don't want this.
> 6:print $1, "\n"; # eq "127.0.0." <- I want this.
>
> use \1 on line 4 and $1 on line 6.
Use $1 in both places.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Mar 1999 21:24:41 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
To: burton@lucent.com
Subject: Re: Regex limits for regex/function calls within subsitutions?
Message-Id: <oeed829ck5i.fsf@alpha.hut.fi>
Burton Kent <burton.not.spam@lucent.com> writes:
> What kind of limits does Perl have on substitutions?
> Is there anything I should watch out for in substitutions?
> (e.g. $text =~ s/this/that/g;)
>
> I get a segmentation fault at a consistent place in a
> substitution operation -- at the end of the replace. I'm
> able to print the value right before returning from the
> replace, but get the segmentation fault as the replace
> returns.
>
> My workaround is to put the subsitution in a subroutine.
> I return the replacement from within the regex, instead of
> letting the replacement part of the expression finish.
>
> The program involves recursively applying regular expression
> substitutions. It seems to fail at about the 4th recursion
> of two nested (with subroutine calls) substitution operations.
> I'm also calling subroutines within the replacement part of
> the regex.
>
> Has anyone else had similar problems?
>
> Burton
Which Perl release? perl -v
That sounds like a serious bug (segmentation fault is always serious).
Could you please prepare a minimal test case and then prepare
a bug report, detailing how to repeat the segmentation fault
(at environment ...?) If you have program called perlbug
installed, use that. If not, send your report directly
to perlbug@perl.com. Thanks.
--
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Tue, 16 Mar 1999 06:05:54 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regex limits for regex/function calls within subsitutions?
Message-Id: <iudlc7.cb8.ln@magna.metronet.com>
Burton Kent (burton.not.spam@lucent.com) wrote:
: What kind of limits does Perl have on substitutions?
: Is there anything I should watch out for in substitutions?
: (e.g. $text =~ s/this/that/g;)
: I get a segmentation fault at a consistent place in a
: substitution operation -- at the end of the replace.
Where is the code that can reproduce the problem for us to look at?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 16 Mar 1999 13:50:12 -0600
From: Burton Kent <burton.not.spam@lucent.com>
Subject: Re: Regex limits for regex/function calls within subsitutions?
Message-Id: <36EEB5F4.76981243@lucent.com>
The version is Perl 5.005_02. Sorry I didn't mention
this before.
Burton
> Which Perl release? perl -v
>
> That sounds like a serious bug (segmentation fault is always serious).
>
> Could you please prepare a minimal test case and then prepare
> a bug report, detailing how to repeat the segmentation fault
> (at environment ...?) If you have program called perlbug
> installed, use that. If not, send your report directly
> to perlbug@perl.com. Thanks.
>
> --
> $jhi++; # http://www.iki.fi/jhi/
> # There is this special biologist word we use for 'stable'.
> # It is 'dead'. -- Jack Cohen
------------------------------
Date: Tue, 16 Mar 1999 14:25:58 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: eric@fruitcom.com
Subject: Re: Slurping multiple files as input
Message-Id: <36EEB046.996719C7@giss.nasa.gov>
[posted and mailed]
Eric Smith wrote:
>
> In bash we go
> for file in `ls $DIR`;do ... $file ...
my @all_files = glob "$DIR/*";
for (@all_files) {
# do something with file name in "$_"
}
--
ping.
------------------------------
Date: Tue, 16 Mar 1999 20:44:28 +0200
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: Re: Sorting Problem
Message-Id: <blade-1603992044280001@durandal.janton.fi>
In article <36ED68D0.8D14D81D@xs4all.nl>, Frank de Bot <debot@xs4all.nl> wrote:
> I have an array:
>
> $ar[0] = "14 || Some Text here";
> $ar[1] = "4 || Lalalala";
> $ar[2] = "7 || Hello World";
>
> How can I sort that the array is this:
>
> $ar[0] = "4 || Lalalala";
> $ar[1] = "7 || Hello World";
> $ar[2] = "14 || Some Text here";
>
> I've tried everything, but nothing worked.
my %ar = map {split /\|\|/, pop @ar} @ar;
for (sort {$a <=> $b} keys %ar) { push @ar, "$_||$ar{$_}" }
HTH
::puts on asbestos underwear::
--
Sami Rosenblad | blade@leela.janton.fi | running Linux since 1999
------------------------------
Date: Tue, 16 Mar 1999 19:22:29 +0100
From: alainch <alain_chiorboli@email.sps.mot.com>
Subject: Sorting with Perl
Message-Id: <36EEA165.B6AD522E@email.sps.mot.com>
Hi all,
I want to sort numerically the keys of a hash table. The keys are as
follows (each key is delimited by a ',')
26.6.1.1, 26.6.2.1.1, 26.6.1.2, 26.6.2.1.2, 26.6.2.3.1, 26.6.2.2,
26.6.1.3, 26.6.2.1.3, 26.6.4.2.1, 26.6.2.3.2, 26.6.1.4, 26.6.1.5,
26.6.4.2.2, 26.6.2.4, 26.6.6.1, 26.6.2.5, 26.6.7.1, 26.6.8.1, 26.6.8.2,
26.6.8.3, 26.6.8.4, 26.6.8.5, 26.6.12.1, 26.6.11.2, 26.6.12.2,
26.6.12.3, 26.6.12.4
So I tryed this: foreach $Test (sort keys %Tab), but the results are not
as expected:
26.6.1.1, 26.6.1.2, 26.6.1.3, 26.6.1.4, 26.6.1.5, 26.6.11.2, 26.6.12.1,
26.6.12.2, 26.6.12.3, 26.6.12.4, , 26.6.2.1.2, 26.6.2.1.3, 26.6.2.2,
26.6.2.3.1, 26.6.2.3.2, 26.6.2.4, 26.6.2.5, 26.6.4.2.1, 26.6.4.2.2,
26.6.6.1, 26.6.7.1, 26.6.8.1, 26.6.8.2, 26.6.8.3, 26.6.8.4, 26.6.8.5
Indeed the key 26.6.11.2 comes before the 26.6.2.1.1, etc...
Then I tryed to sort by this way : foreach $Test (sort {$a <=> $b} keys
%Tab) , and the results are still not good!
26.6.1.1, 26.6.2.1.1, 26.6.1.2, 26.6.2.1.2, 26.6.2.3.1, 26.6.2.2,
26.6.1.3, 26.6.2.1.3, 26.6.4.2.1, 26.6.2.3.2, 26.6.1.4, 26.6.1.5,
26.6.4.2.2, 26.6.2.4, 26.6.6.1, 26.6.2.5, 26.6.7.1, 26.6.8.1, 26.6.8.2,
26.6.8.3, 26.6.8.4, 26.6.8.5, 26.6.12.1, 26.6.11.2, 26.6.12.2,
26.6.12.3, 26.6.12.4
Indeed the key 26.6.2.1.1 comes before the 26.6.1.2, etc...
Does anyone know how to handle this kind of sorting ?
--
_____________________________________________________________________
Alain CHIORBOLI
Email : alain_chiorboli@email.sps.mot.com
_____________________________________________________________________
------------------------------
Date: Tue, 16 Mar 1999 14:20:13 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sorting with Perl
Message-Id: <comdog-ya02408000R1603991420130001@news.panix.com>
In article <36EEA165.B6AD522E@email.sps.mot.com>, alainch <alain_chiorboli@email.sps.mot.com> posted:
> I want to sort numerically the keys of a hash table. The keys are as
> follows (each key is delimited by a ',')
> 26.6.1.1, 26.6.2.1.1, 26.6.1.2, 26.6.2.1.2, 26.6.2.3.1, 26.6.2.2,
> 26.6.1.3, 26.6.2.1.3, 26.6.4.2.1, 26.6.2.3.2, 26.6.1.4, 26.6.1.5,
> 26.6.4.2.2, 26.6.2.4, 26.6.6.1, 26.6.2.5, 26.6.7.1, 26.6.8.1, 26.6.8.2,
> 26.6.8.3, 26.6.8.4, 26.6.8.5, 26.6.12.1, 26.6.11.2, 26.6.12.2,
> 26.6.12.3, 26.6.12.4
> Does anyone know how to handle this kind of sorting ?
you can write your own sort subroutine. if i understand correctly
what you would like, something like the following could work:
sub my_way
{
my @a = split /\./, $a;
my @b = split /\./, $b;
foreach my $index ( 0..$#a )
{
return 1 if $a[$index] > $b[$index];
return -1 if $a[$index] < $b[$index];
next if $a[$index] == $b[$index]; #not really needed
}
return 0;
}
@sorted = sort my_way keys %hash; #i did it my waaaay...
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 16 Mar 1999 10:58:54 -0800
From: "Ekkis" <ekkis@arix.com>
Subject: symbolic method references?
Message-Id: <uRxH2.10100$TD3.106056@typhoon-sf.pbi.net>
In a package I wrote I had used the following:
$f = shift; &$f() if defined &$f;
I'm now converting the package to a class so the function's become a method.
I can call it but can't figure out how to test for it's presence:
$f = shift;
$o = TST->new();
$o->$f(); # works fine
$o->$f() if defined &$o->$f; # dn't work
I've searched through a lot of postings on this group and the docs but found
no close answer and am feeling like a dodo.
TIA - e
------------------------------
Date: Tue, 16 Mar 1999 19:41:15 +0000
From: Bill Anderson <banderson@boi.hp.com>
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <36EEB3DB.779FD60D@boi.hp.com>
Tim Roberts wrote:
>
> John Lehmann <johnl@axis.com.au> wrote:
>
> >Kano wrote:
> >>
> >> Oh come on. Many other standard devices (ethernet cards, for example)
> >> have their
> >> own unique serial numbers that software can use at will. Get over it.
> >>
> >
> >Yes - but ethernet mac cards are only broadcast over the lan, not over
> >the net (except by Office98, of course).
>
> The POINT here is that it is exactly as easy to embed my unique MAC address
> in an Internet transaction as it is to embed my unique Pentium-III CPU ID
> in an Internet transaction. Any software which will go to the trouble to
> fetch the unique CPU identifier and send it over the network to identify me
> could just as easily be written TODAY to use a MAC address for exactly the
> same purpose. The CPU identifier is not significantly different in concept
> from the MAC address, and yet there has not been a hue and cry to boycott
> NIC manufacturers.
Ho wmany home users ar LAN connected to the internet?
oh, yeah, that's right, they dial up with a modem; no getting a MAC
address from a machine that does not have one.
>
> >And what do you mean get over it??? This kind of personal information
> >is valuable. Business are willing to pay for it. This kind of
> >behavior IS DOWNRIGHT THEFT!!!
>
> But whatever they could do with a CPU ID, they are probably already doing
> with a MAC address. It is just as good as a unique identifier. "Get over
> it" is exactly the right attitude.
Can you explain how they would be getting a MAC address from my friends'
NIC-less pc?
A MAC address is not as good, in any event. NICs get changed mor often
than cpus (in most cases). IIRC MAC addresses can be changed, and there
have been cases of MAC addresses beinf reused?
------------------------------
Date: Tue, 16 Mar 1999 11:49:55 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Unable to find load file LS
Message-Id: <36EEB5E3.14630F82@mail.cor.epa.gov>
John Kloss wrote:
>
> Hello,
>
> I am very new to Perl and programming in general. I am hoping someone out
> there will help me out with my dilema.
>
> I have a script that searches directories on my web server( a very simple
> script). When I run the script I get all the HTML output that I am supposed
> to but no search results. I check the server logs and get the message:
>
> Unable to find load file LS
>
> The server is a Netscape Enterprise 3.0 running on a Novell O/S
>
> Any help would be greatly appreciated
>
> Thanks,
> John Kloss
John, this is not a Perl error message. (Typing 'perldoc perldiag' will
show you the list, with explanations.) So this is likely to be the wrong
newsgroup for your question. Have you checked to see whether there are
newsgroups covering Nyetscape's Enterprise Server?
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 16 Mar 1999 14:35:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Web Programming
Message-Id: <comdog-ya02408000R1603991435250001@news.panix.com>
In article <36EDC9CF.314C00A0@utk.edu>, Jay Flaherty <fty@utk.edu> posted:
> Travis Leuthauser wrote:
> >
> > I am trying to write a perl script which will display a dislaimer, have
> > the web user agree to the terms of the agreement, then call itself again and
> > bring up a simple form for the user to fill out. The reason I would like
> > everything in the same script is to force every user to read the disclaimer
> > first. If there is a better way, I am certainly open to suggestions. This
> > is being written for an Apache web server. Any help would be greatly
> > appreciated.
>
> Good idea. You will need to track the user somehow to see if he read the
> disclaimer page. Using the environment variable $ENV{'HTTP_REFERER'} can
> work
ick. bad idea.
>but only if you don't have other pages to go to from the form page.
> You can use hidden fields but this can easily be gotten around. Your
> best bet is to use cookies.
the best bet is use something in the URL. notice Amazon.com's method.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 16 Mar 1999 11:59:25 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Which is better for Windows use: perl or python
Message-Id: <36EEB81D.C573BACC@mail.cor.epa.gov>
Franz Kaufmann wrote:
> Hello.
> I wonder what language is better suited for windows specific stuff (COM
> a.s.o) :Perl or Python
> Can anyone help me with this?
> Thank you in advance,
> Bye.
Franz,
This might start a war if cross-posted. Language vs language
discussion tend to get heated. But this newsgroup tends to be more
rational on the issue than most.
IMHO, you should examine what you want to get done, then decide
which language has modules making your task easier *for* *you* to
do it. Both are very capable languages. I prefer Perl myself,
but then consider in what group I'm posting. If you choose Perl,
be sure to look at all the modules available for Windows.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 16 Mar 1999 11:55:24 -0800
From: mbudash@trantracks.com (Michael Budash)
Subject: which version of perl5/lwp should we be using?
Message-Id: <mbudash-1603991155240001@d72.nas1.napa.sonic.net>
while debugging a client's rather annoying lwp-related problem for the
past two months, i was finally able to determine the problem's cause, as
well as a what may be potential for more trouble in the future. allow me
to elaborate:
1 - the default version of perl running on my client's irix server is
5.003, although 5.00404 and 5.00502 are also available. changing my
client's script to point to 5.00404 fixed his problem, though i really
have no idea why...
2 - the _only_ version of the lwp perl module that is available on my
client's server is 5.01, although the latest version on cpan is 5.36.
questions:
what version of perl for irix should i consider the "latest" without going
"beta"? is there some reason they host (hiway.com) would choose to stop at
5.003? i don't profess in any way to know all that much about the working
and versions of perl, but i *do* know that i spent 2 months running down a
problem that doesn't appear to be caused by me!!
also: should i ask for the latest version of LWP to be installed? is it a
potential problem for 5.01 to be there?
tia-
--
@-----------------------------@--------------------@
| Michael Budash Consulting | 707-255-5371 |
| Perl, Javascript, Html | 707-258-7800 x7736 |
| Official Extropia Developer | mbudash@sonic.net |
@-----------------------------@--------------------@
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5149
**************************************