[15975] in Perl-Users-Digest
Perl-Users Digest, Issue: 3387 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 16 06:10:24 2000
Date: Fri, 16 Jun 2000 03:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <961150214-v9-i3387@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 16 Jun 2000 Volume: 9 Number: 3387
Today's topics:
Scripts work from shell but not browser <steveNOstSPAM@betterwaywebsites.com.invalid>
Re: Scripts work from shell but not browser (Abigail)
Re: Sort arrays of arrays? (Rafael Garcia-Suarez)
Re: Sorting a ':' delimeted file by a field value/surna <lyndon@xellent.co.uk>
Re: Sorting a ':' delimeted file by a field value/surna <blah@nospam.com>
Re: Sorting a ':' delimeted file by a field value/surna <h.camp@scm.de>
Re: Sorting a ':' delimeted file by a field value/surna <abe@ztreet.demon.nl>
Re: Taryag Perl meirman@QQQerols.com
Re: uses for PERL <pdcawley@bofh.org.uk>
Re: Where are the error logs? (Bart Lateur)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 Jun 2000 00:51:05 -0700
From: Steve Harder-Kucera <steveNOstSPAM@betterwaywebsites.com.invalid>
Subject: Scripts work from shell but not browser
Message-Id: <03637eba.4ca32cc4@usw-ex0104-033.remarq.com>
I've only been writing perl scripts for a few months now. I wrote
them on one server and successfully moved them to another server
with no major hassles.
I recently moved them to a third server and now I am stumped. I
started getting Internal Server Errors. I checked all the file
permissions and paths, and the syntax checks out from the unix
shell.
I started to debug them line by line and found that they were
getting hung up on the "die" function. I experimented with
commenting out the die routine and the scripts run, but they
don't actually open, ammend, modify etc.. the files as they
should.
What is strange to me is that when I run the scripts via the unix
shell, they work perfectly. No syntax errors, and they actually
do what they are supposed to do.
The version of perl where they work is 5.005.02
The version where they don't work is 5.005, patch 03
Here is a sample of the die routine as it is written:
open (INPUT, "$data_file") || die "Can't open $data_file for
input - $!\n";
To a more experienced programmer, this may be a no-brainer, but
I'm stumped. I'm especially perplexed by the fact that it works
fine from the shell. I need them to work via a graphical browser.
Any thoughts, hints or shoves in the right direction would be
appreciated. Please let me know if you need more info.
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: 16 Jun 2000 04:50:29 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Scripts work from shell but not browser
Message-Id: <slrn8kjrkt.kp1.abigail@alexandra.delanet.com>
Steve Harder-Kucera (steveNOstSPAM@betterwaywebsites.com.invalid) wrote
on MMCDLXXXI September MCMXCIII in <URL:news:03637eba.4ca32cc4@usw-ex0104-033.remarq.com>:
?? I've only been writing perl scripts for a few months now. I wrote
?? them on one server and successfully moved them to another server
?? with no major hassles.
On a "server"? What kind of "server"? Usually, a server is a process,
do you use some kind of "perl server", what ever that might be?
?? I recently moved them to a third server and now I am stumped. I
?? started getting Internal Server Errors. I checked all the file
?? permissions and paths, and the syntax checks out from the unix
?? shell.
Well, I guess you have a bug then. Somewhere.
However, "Internal Server Error" isn't a Perl error. All Perl errors
are in perldiag.pod. This file however has a section about "Server error".
Please read it, and pay attention to the part in bold.
?? I started to debug them line by line and found that they were
?? getting hung up on the "die" function.
How surprising. Considering that you are using die, I assume you know
what die does. But if you know what it does, you should be surprised
at all.
?? I experimented with
?? commenting out the die routine and the scripts run, but they
?? don't actually open, ammend, modify etc.. the files as they
?? should.
Well, and what kind of reason did Perl report? Or are you just ignoring
the return value of open, and you prefer people here guessing for the
reason - a reason you could have found in 1% of the time it took to
write your posting?
?? What is strange to me is that when I run the scripts via the unix
?? shell, they work perfectly. No syntax errors, and they actually
?? do what they are supposed to do.
Could you be a bit more vague in what you have done, and what kind
of problems you are experiencing? Now there's still a chance a set
of a million monkeys randomly typing on typewriters for a million
years might actually type the solution to your problem.
?? The version of perl where they work is 5.005.02
?? The version where they don't work is 5.005, patch 03
??
?? Here is a sample of the die routine as it is written:
??
?? open (INPUT, "$data_file") || die "Can't open $data_file for
?? input - $!\n";
And, what *was* the die message?
?? To a more experienced programmer, this may be a no-brainer, but
?? I'm stumped.
I'm stumped on why you are stumped. You open a file, and die with
a message giving the reason if the open fails. The open fails, and
you are utterly confused. You totally ignore the reason why the
open fails, and you simple remove the die. Then you are confused
it no longer dies, but still doesn't open.
?? I'm especially perplexed by the fact that it works
?? fine from the shell. I need them to work via a graphical browser.
Perl doesn't care whether it's called via a browser or not. And I highly
doubt the browser is relevant. I smell CGI, and with CGI, there is *NO*
communication between the browser and the Perl program. There's always
the middle man.
?? Any thoughts, hints or shoves in the right direction would be
?? appreciated. Please let me know if you need more info.
The groups about CGI problems are down the hall, to your left.
Just follow the smell.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Fri, 16 Jun 2000 07:07:31 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: Sort arrays of arrays?
Message-Id: <slrn8kjkp0.5n3.garcia_suarez@rafael.kazibao.net>
Henrik Jönsson wrote in comp.lang.perl.misc:
>Hi,
>
>I have a script that keep track of which files that are downloaded
>from my site. The hits are stored in a seperate file in the format:
>
>url|numberOfHits
>
>Now I want to sort this file with the number of hits as the sort key.
>
>I inserted the url and numberOfHits in an array. But how do I sort
>this array?
Assuming @hits contains your two-element arrays [url,num_of_hits], this code
will sort it:
my @sorted_hits = sort { $a->[1] <=> $b->[1] } @hits;
See perldoc -f sort
--
Rafael Garcia-Suarez
------------------------------
Date: Fri, 16 Jun 2000 08:41:06 +0100
From: "Lyndon Leggate" <lyndon@xellent.co.uk>
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <3949da70@news.server.worldonline.co.uk>
another way ... maybe a bit more long-winded though .... however it can sort
by multiple fields:
open(DB,"your-file.db");
@db = <DB>;
close(DB);
for $i(0..$#db) {
chomp $db[$i];
@tempinfo = split(/:/,$db[$i]);
$db[4] =~ tr/A-Z/a-z/;
$db[2] =~ tr/A-Z/a-z/;
# note first "." is a single full stop / dot ..... second ":" is whatever
your delimter is
$sortinfo[$i] = $db[4] . "." . $db[2] . ":" . $db[$i];
}
@finalstring = sort(@sortinfo);
for $i(0..$#sortinfo) {
@tempsortedinfo = split(/:/,$sortinfo[$i]);
for $i2(1 .. $#tempsortedinfo) {
$finaloutput[$i] = ":" . $tempsortedinfo[$i2];
$finaloutput[$i] =
substr($tempsortedinfo[$i2],1,length($tempsortedinfo[$i2]));
}
}
and there you go ... the finished sorted array is now in @finaloutput ...
your initial array will be sorted by $db[4] field initially ... then by the
$db[2] field ... you can add further fields in there to be sorted as well
.... i.e. surname, first name, middle name etc etc.....
Hope this helps,
Lyndon Leggate
"Fabio Niski" <fabion@sti.com.br> wrote in message
news:394952E4.F5622D61@sti.com.br...
>
>
> Fabio Niski wrote:
>
> > well, first..split the file
> > while <BLA> {
> > ...
> > ($arr[0], $var[1], $var[2]) = split (/:/, $_);
>
> sorry
> ($arr[0], $arr[1], $arr[2]) = split (/:/, $_);
>
>
------------------------------
Date: Fri, 16 Jun 2000 10:52:31 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <3949EACF.C008F3BA@nospam.com>
Larry,
Larry Rosler wrote:
>>> I'm looking for a way to sort a text file (example below),
>>> it's delimited by : I need to sort lines according to surname.
>>> I'm working with Macperl, and I'm trying to do all the coding
>>> my self (not using that many fancy Modules due to "portability".
>>> Has anyone any Ideas on how to sort the lines in alphabetical
>>> order, A-Z (to add extra spice I need to sort the swedish
>>> chars =E5=E4=F6 as well).
> Unless those characters are already in the correct sequence
> relative to each other and to the ASCII characters,you cannot do
> that with the default lexicograpic sort.
Your are right, but I can not see those charcters: =E5=E4=F6... :(
> You will need to tailor a sortsub to your needs.
Not really needed, I think: I have not tried, but seems that the
locale pragma sets the perl interpreter in order to use locale-related
functions. Obviously, the locale sub-system must be correctly
configured on the target platform.
<code>
use locale;
print (sort { (split /:/,$a)[3] cmp (split /:/,$b)[3] } <>)
</code>
>> <code>
>> while (<>) { $sorted{(split /:/)[4]}=3D$_ }
> ^
> 3
What is it that '3D' between the '=' and the '$_'?
Best regards,
Marco
------------------------------
Date: 16 Jun 2000 09:42:02 GMT
From: Hartmut Camphausen <h.camp@scm.de>
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <8icspa$if9$1@surz18.HRZ.Uni-Marburg.DE>
[Fup zu Fabio Niski's Posting vom Thu, 15 Jun 2000 19:03:30 -0300]
> well, first..split the file
> while <BLA> {
> ...
> ($arr[0], $var[1], $var[2]) = split (/:/, $_);
Thougth of $arr[1] instead of $var[1]?
> then , to sort the array in alphabetical order try
>
> @arr = sort { $a cmp $b } @arr;
Well, this will compute quite fast, since @arr contains how many
elements? Just 3, extracted from the last line of BLA.
Hmm. Not that good.
Maybe we should try to let our @arr grow:
#!perl.exe -w
use strict;
my $field_index = 1; # or whatever field you need to sort on
my @arr;
++$field_index; # need to split into n+1 fields
foreach my $line (<BLA>) {
push @arr, [ split (':', $line, $field_index) ];
}
Note that a /reference/ to an anonymous array is push()ed.
Note that the last field of @{$arr[n]} ($arr[n]->[-1]) contains the
possibly un-split()ted remainder of $line.
Now do some sorting:
my @sorted = sort {$a->[-2] cmp $b->[-2]} @arr;
Now @sorted contains references to each BLA-line (as an array) in the
right order.
TODO:
check for $field_index == 0 (where 1 means first column);
check what happens if $field_index points to the last column
hth + mfg, Hartmut
--
CREAGEN Computerkram Fon: 06424/923826
Hartmut Camphausen Fax: 06424/923827
Kirchstrasse 8 Emil: h.camp@creagen.de
35043 Marburg WWW: http://www.creagen.de/
------------------------------
Date: Fri, 16 Jun 2000 11:57:33 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <uksjkso3hen2dgt68sfv9f06vjutg7b5i4@4ax.com>
On Fri, 16 Jun 2000 08:41:06 +0100, "Lyndon Leggate"
<lyndon@xellent.co.uk> wrote:
> another way ... maybe a bit more long-winded though .... however it can sort
> by multiple fields:
Well no, it can't!
> open(DB,"your-file.db");
Always check the result of that open:
open DB, 'you-file.db' or die "Cannot open 'your-file.db': $!";
> @db = <DB>;
> close(DB);
>
> for $i(0..$#db) {
This is not a Perlish way to do what you want. Read the suggested
readings later on to pick up on this.
> chomp $db[$i];
> @tempinfo = split(/:/,$db[$i]);
> $db[4] =~ tr/A-Z/a-z/;
That 'lower cases' the fifth line of the original file
$tempinfo[4] =~ tr/A-Z/a-z/;
> $db[2] =~ tr/A-Z/a-z/;
That 'lower cases' the third line of the original file
$tempinfo[2] =~ tr/A-Z/a-z/;
> # note first "." is a single full stop / dot ..... second ":" is whatever
> your delimter is
> $sortinfo[$i] = $db[4] . "." . $db[2] . ":" . $db[$i];
That creates a string composed of
the fifth line of the file (lower cased)
the third line of the file (lower cased)
the ($i+1)th line of the file
This is not going to influence the way the file is sorted
Even if you use (what you probably meant):
$sortinfo[$i] = "$tempinfo[4].$tempinfo[2]:$db[$i]";
There is no fair sort-key there, as the sizes of $tempinfo[4] and
$tempinfo[2] are not fixed.
If you want to do such type of smart sorting you might want to read
about GRT:
http://www.hpl.hp.com/personal/Larry_Rosler/sort/sorting.html
But you probably should read a good explanation of Schwartzian Transform
first:
http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html
--
Good luck,
Abe
------------------------------
Date: Fri, 16 Jun 2000 04:47:51 -0400
From: meirman@QQQerols.com
Subject: Re: Taryag Perl
Message-Id: <haqjks0n45ssr7mjv8e5msh3ko97sn31g6@4ax.com>
In soc.culture.jewish on Fri, 16 Jun 2000 02:46:37 -0400
meirman@QQQerols.com posted:
>In soc.culture.jewish on Thu, 15 Jun 2000 20:59:38 GMT
>cberry@cinenet.net (Craig Berry) posted:
>
>>Drew Simonis (care227@attglobal.net) wrote:
>>: Tad McClellan wrote:
>>: > >> Is it just a coincidence that ActiveState's lastest
>>: > >> release is "build 613"? I think not.... :)
>>: > >
>>: > >A coincidence with what?
>>: >
>>: > What is "Taryag"?
>>:
>>: It seems to be very closley related to the number 613.
>>: Mystical, I bet!
>>
>>Well, using the standard Hebrew letter->number mapping, it adds up to 613
>>(tav-resh-yod-gimel, 400+200+10+3=613.)
>
>Very good. All you guys are great, including Tom who was right and
>shouldn't be so hard on himself.
Could have phrased that better. Add, Even if you hadn't been right,
you shouldn't be so hard on yourself. Esp. since you ended with 'or
something'.
>
>Crossposting at its finest.
>
>
>meirman@QQQerols.com
>e-mail by removing QQQ
meirman@QQQerols.com
e-mail by removing QQQ
------------------------------
Date: 16 Jun 2000 08:59:59 +0100
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: uses for PERL
Message-Id: <m1bt12jbsw.fsf@rt158.private.realtime.co.uk>
cberry@cinenet.net (Craig Berry) writes:
> Mark-Jason Dominus (mjd@plover.com) wrote:
> : In article <skam18qhh5157@corp.supernews.com>,
> : Craig Berry <cberry@cinenet.net> wrote:
> : >(*) Note that a true Turing-complete language demands infinite memory
> : >storage, a sticking point which is normally ignored.
> :
> : No, it only demands unbounded memory storage. An ordinary tape drive
> : will serve, as long as the program will pause and wait for you to find
> : another blank tape when it needs one.
>
> That's functionally equivalent to infinite memory storage.
Not quite actually. With unbounded memory available then the amount of
memory used will always be finite, though it may get very big. One of
Martin Gardeners columns in Scientific American had a discussion of
some processes whose runtime was unbounded but finite. It gets
non-intuitive pretty darned quickly.
--
Piers
------------------------------
Date: Fri, 16 Jun 2000 09:47:22 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Where are the error logs?
Message-Id: <394df56d.4624245@news.skynet.be>
Johnny wrote:
>I'm using Perl on an NT IIS server and can't seem to find the error logs that I
>was hoping would help me debug my perl scripts.
>
>Any ideas where they are?
No, but you could send your error messages to the browser. CGI::Carp
probably will be a good starting point, and the term "fatalsToBrowser"
is one I distinctly remember.
But... but... this doesn't send warnings to the browser?
--
Bart.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3387
**************************************