[10111] in Perl-Users-Digest
Perl-Users Digest, Issue: 3704 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 13 13:07:59 1998
Date: Sun, 13 Sep 98 10:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 13 Sep 1998 Volume: 8 Number: 3704
Today's topics:
[Q] How modify file? <okcivil@soback.kornet.nm.kr>
Re: [Q] How modify file? <okcivil@soback.kornet.nm.kr>
Re: [Q] How modify file? <okcivil@soback.kornet.nm.kr>
Re: ANN: Backwards.pm (Jonathan Stowe)
Re: ANN: Backwards.pm (Mark-Jason Dominus)
C++ extensions <nickg@glencros.demon.co.uk>
Re: Change NT IP Address Using Perl (Jonathan Stowe)
Re: getc function from STDIN (Gabor)
Re: How to getc like in C? (Gabor)
Re: majordomo for perl.moderated? (Mark-Jason Dominus)
Re: Off topic, but ... [Was Re: Perl & Java - differenc (Jonathan Stowe)
perl scripts doesn't work concurrently on "background" <dadman@brainsys.cz>
Re: Problem calling executables from Win95 ('General fa posenj@lancet.co.za
Re: REMOTE_USER ENV variable trapping <chris@mobiles.demon.co.uk>
Re: Retrieve file from PC using LWP::UserAgent? <cglcomputer@earthlink.com>
Search textfile? <mattias@mjolby.nu>
Re: Search textfile? <rick.delaney@shaw.wave.ca>
Seeking Perl program to transfer files between machines (Jeremy Mathers)
Re: Sorting Arrays of Hashes.. (David A. Black)
Re: Sorting Arrays of Hashes.. <cglcomputer@earthlink.com>
Suidperl is obstructed, but by what? <joreb@algonet.se>
Re: Suidperl is obstructed, but by what? <garry@america.net>
Very slow cgi-bin execution (Luc de Louw)
Re: Very slow cgi-bin execution (Mike Stok)
Re: Very slow cgi-bin execution (Andrew M. Langmead)
Re: Why does this sort work in Dos but not in Unix? (David A. Black)
Re: {{{ Programmer Needed... }}} <jimbo@soundimages.co.uk>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Sep 1998 13:55:34 GMT
From: Park <okcivil@soback.kornet.nm.kr>
Subject: [Q] How modify file?
Message-Id: <6tgism$lh2$2@news.kornet.nm.kr>
Hi.
How modify file? It is fixed length data.
open (DATA, "data.dat");
seek (DATA, 3);
And.. Next.. How can I input data in data.dat?
--
________________________---------------------------________________________
________________________--------- OK CLUB ---------________________________
email : okpolis@nownuri.NOWCOM.CO.KR / OKCIVIL@SOBack.kornet.nm.kr
the world will be astonISHED WHEN WE WAKE UP. =!= rise for actualization
________________________---------------------------________________________
------------------------------
Date: 13 Sep 1998 14:27:48 GMT
From: Park <okcivil@soback.kornet.nm.kr>
Subject: Re: [Q] How modify file?
Message-Id: <6tgkp4$o0b$1@news.kornet.nm.kr>
Park <okcivil@soback.kornet.nm.kr> wrote:
Sorry. My question wasn't accuracy.
open file
seek file 3 0;
write "abc" in file
close file
I wanna input "abc" char in file. it is fixed length data.
I tried...
open (FILE, ">>data.dat");
seek (FILE, 3, 0);
$abc = "abc";
syswrite (FILE, $abc, 3, 3);
close (FILE);
it dosn't work.
: Hi.
: How modify file? It is fixed length data.
: open (DATA, "data.dat");
: seek (DATA, 3);
: And.. Next.. How can I input data in data.dat?
:
: --
: ________________________---------------------------________________________
: ________________________--------- OK CLUB ---------________________________
: email : okpolis@nownuri.NOWCOM.CO.KR / OKCIVIL@SOBack.kornet.nm.kr
: the world will be astonISHED WHEN WE WAKE UP. =!= rise for actualization
: ________________________---------------------------________________________
--
________________________---------------------------________________________
________________________--------- OK CLUB ---------________________________
email : okpolis@nownuri.NOWCOM.CO.KR / OKCIVIL@SOBack.kornet.nm.kr
the world will be astonISHED WHEN WE WAKE UP. =!= rise for actualization
________________________---------------------------________________________
------------------------------
Date: 13 Sep 1998 15:53:32 GMT
From: Park <okcivil@soback.kornet.nm.kr>
Subject: Re: [Q] How modify file?
Message-Id: <6tgpps$5un$2@news.kornet.nm.kr>
I found answer myself.
open (FILE, "+<data.dat");
seek ...
syswrite ...
close ...
If you have more good coding, plz write.
Park <okcivil@soback.kornet.nm.kr> wrote:
: Park <okcivil@soback.kornet.nm.kr> wrote:
: Sorry. My question wasn't accuracy.
: open file
: seek file 3 0;
: write "abc" in file
: close file
: I wanna input "abc" char in file. it is fixed length data.
: I tried...
: open (FILE, ">>data.dat");
: seek (FILE, 3, 0);
: $abc = "abc";
: syswrite (FILE, $abc, 3, 3);
: close (FILE);
: it dosn't work.
: : Hi.
: : How modify file? It is fixed length data.
: : open (DATA, "data.dat");
: : seek (DATA, 3);
: : And.. Next.. How can I input data in data.dat?
: :
: : --
: : ________________________---------------------------________________________
: : ________________________--------- OK CLUB ---------________________________
: : email : okpolis@nownuri.NOWCOM.CO.KR / OKCIVIL@SOBack.kornet.nm.kr
: : the world will be astonISHED WHEN WE WAKE UP. =!= rise for actualization
: : ________________________---------------------------________________________
: --
: ________________________---------------------------________________________
: ________________________--------- OK CLUB ---------________________________
: email : okpolis@nownuri.NOWCOM.CO.KR / OKCIVIL@SOBack.kornet.nm.kr
: the world will be astonISHED WHEN WE WAKE UP. =!= rise for actualization
: ________________________---------------------------________________________
--
________________________---------------------------________________________
________________________--------- OK CLUB ---------________________________
email : okpolis@nownuri.NOWCOM.CO.KR / OKCIVIL@SOBack.kornet.nm.kr
the world will be astonISHED WHEN WE WAKE UP. =!= rise for actualization
________________________---------------------------________________________
------------------------------
Date: Sun, 13 Sep 1998 11:23:54 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: ANN: Backwards.pm
Message-Id: <35fbaaa2.3365144@news.btinternet.com>
On 12 Sep 1998 23:45:21 -0400, Uri Guttman wrote :
>
>here is a working (may need some real world testing) module that reads a
>file backwards by line.
And I just thought MJD's proposal was a joke ;-}
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 13 Sep 1998 12:15:28 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: ANN: Backwards.pm
Message-Id: <6tgr30$cqt$1@monet.op.net>
In article <35fbaaa2.3365144@news.btinternet.com>,
Jonathan Stowe <Gellyfish@btinternet.com> wrote:
>And I just thought MJD's proposal was a joke ;-}
Nope.
When I propose Sideways.pm, that's a joke.
------------------------------
Date: 13 Sep 1998 10:00:03 +0000
From: Nick Glencross <nickg@glencros.demon.co.uk>
Subject: C++ extensions
Message-Id: <m367es72os.fsf@glencros.demon.co.uk>
Hi All!
I recall about a year ago seeing a posting regarding this, but
didn't see the followups.
I've had a Perl extension written in C++ statically linked (it was on
a platform on which gcc didn't support shared libs) with Perl and it
has worked very well. I now have Linux and want it dynamically loaded.
Unfortunately it core dumps whenever a call to a stream (including a
newly created one) is made. My hunch over the last few days has been
that there is a static object or buffer which doesn't initialise since
the top-level file doesn't do it's C++ startup. I've tried to study
the source for libg++ but I can't find good reason for it.
Can anyway suggest a workaround? or must I recompile perl and link it
again libg++? The last thing that I want to do is change all my
couts/cerrs to printf's!
I can reproduce it with a small module, so if you need an example I
follow-up with one.
Thanks,
Nick Glencross
------------------------------
Date: Sun, 13 Sep 1998 11:23:53 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Change NT IP Address Using Perl
Message-Id: <35fba8bd.2880267@news.btinternet.com>
On 13 Sep 1998 01:40:59 GMT, Gregory Spath wrote :
>On Sat, 12 Sep 1998 14:29:20, Gellyfish@btinternet.com (Jonathan
>Stowe) wrote:
>
>>
>> Rexx, Rexx ? I would recommend comp.lang.rexx then buddy. ;-}
>>
>
>Hey, now. I'm a perl coder now too, and have converted a bunch of my
>REXX stuff (quite easily, I might add)
>
>REXX is still better at some tasks, although I'm liking perl quite a
>bit.
>
>(and take a look at the groups you crossposted to in your followup
>there, buddy ;-)
>
Hmm and one of them didnt exist anymore :)
I have dabbled with REXX I must admit - but never having done a great
deal of IBM stuff there was no impetus. I think I compiled it on my
Linux box though - and then there was ARexx on the old Amiga.
I'm not a language evangelist though.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 13 Sep 1998 12:53:44 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: getc function from STDIN
Message-Id: <slrn6vng1g.9bf.gabor@guava.vmunix.com>
In comp.lang.perl.misc, Abbas Imani <@ikorn.ee.unsw.edu.au> wrote :
# Hello everybody,
#
# I am trying to have one character input and am using getc function.
#
# I have two problems:
#
# 1. I would like the program to continue when one key is hit. In other
#
# words, I do not want the user to have to hit enter key after s/he
#
# hits a key.
#
# 2. After I use getc(STDIN) in my code, I can not use the command
#
# for the second time in the same code. The program doesn't wait for
#
# the user to hit any key. How can I fix this.
Quick and dirty way is to use
system 'stty cbreak'; # optionally, -echo as well
whatever
system 'stty cooked';
or use the module Term::ReadKey.
------------------------------
Date: 13 Sep 1998 12:39:01 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: How to getc like in C?
Message-Id: <slrn6vnf5t.9bf.gabor@guava.vmunix.com>
In comp.lang.perl.misc, Julian Gilbey <J.D.Gilbey@qmw.ac.uk> wrote :
# Abbas Imani wrote:
# >
# > Hi All,
# > I am trying to write a menu type of thing for my perl script. I would
# > like to have one
# > character input without having to hit 'enter' key. In other words I like
# > to have something like
# > getc in c. The getc command in Perl acts like getchar in C.
# > Cheers,
# > Abbas
getc in perl can take a FILEHANDLE and then act like getc in C or not take
a FILEHANDLE and act like getchar.
perldoc -f getc
------------------------------
Date: 13 Sep 1998 11:47:56 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: majordomo for perl.moderated?
Message-Id: <6tgpfc$cni$1@monet.op.net>
In article <35faca68.83983455@news.btinternet.com>,
Jonathan Stowe <Gellyfish@btinternet.com> wrote:
>Having said that it might be possible that an e-mail gateway for the
>group exists of whose existence I am ignorant.
Russ is setting up a mailing list version of the moderated group.
------------------------------
Date: Sun, 13 Sep 1998 11:23:51 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Off topic, but ... [Was Re: Perl & Java - differences and uses]
Message-Id: <35fba7da.2653646@news.btinternet.com>
On Sat, 12 Sep 1998 21:47:43 -0400, Matthew O. Persico wrote :
>Jim Brewer wrote:
>>
>> Hey, what about the Atlantic Ocean. That's a REAL DMZ. Shielding us
>> from North America. Funny that. Big, cold, deep. Perfect.:)
>
>No Jim, your most important DMZ is the Channel!
>
Yeah but now we got The Tunnel. I mean I only live thirty miles from
France - nearer than London.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sun, 13 Sep 1998 15:53:30 +0200
From: "Jakub Dadak" <dadman@brainsys.cz>
Subject: perl scripts doesn't work concurrently on "background"
Message-Id: <6tgj8r$au7$1@adis.cesnet.cz>
Hi,
i've run two perl scripts using nohup script &;
First script 1.pl in some occurences run special program
system("/usr/bin/program &"); which send audio data to /dev/dsp (linux).
All running well, but when i run script two (2.pl = only simple tcp server)
nohup 2.pl & then 1.pl writes error messages that he can't open /dev/dsp !!!
Why !!! 2.pl doesn't use /dev/dsp but 1.pl can't used /dev/dsp.
When I run script 1.pl and 2.pl on foreground they running well.
Where is a problem ?
Thanks
JD
--
,{(~)~(}, Dadak Jakub Brain Systems s.r.o.
,( ((~) ){){} dadman at brainsys.cz Rybkova 1
())~{)}{{}~()} http://www.brainsys.cz Brno 602 00
`~^ ^~{()} Tel. +420 5 41148704 Fax. +420 5 41148852
~~ Motto: Things are different !
------------------------------
Date: Sun, 13 Sep 1998 04:02:31 GMT
From: posenj@lancet.co.za
Subject: Re: Problem calling executables from Win95 ('General failiure' on A: when there is no reference to A:)
Message-Id: <35fb43cb.30082729@news.saix.net>
On Sun, 09 Aug 1998 02:31:16 GMT, posenj@lancet.co.za wrote:
;kjgblkjghnlkuy
>When calling any external program (located on my C: drive) from the
>script my A: drive is accessed. I get the following message:
>
> General failure reading device LP!!?
> Abort, Retry, Fail?
>
>After selecting 'Fail' twice the execution seems to continue as
>normal.
>
>I have searched my registry for any references to both 'Perl' and 'A:'
>and removed them all. I also deleted all my histories ('Run',
>'Documents', etc).
>
>No success.
>
>When callng any of these programs without using the script they work
>perfectly.
>
>Can anyone shed some light on this?
>
>Kevin Posen
>Johannesburg, South Africa
------------------------------
Date: Sun, 13 Sep 1998 14:28:34 +0100
From: Chris Conwell <chris@mobiles.demon.co.uk>
Subject: Re: REMOTE_USER ENV variable trapping
Message-Id: <hoJaZDACi8+1EAqc@mobiles.co.uk>
>We are operating a web that does not restrict general access. We provide
>restricted password access by setting protection on the htm that calls the
>scripts. The problem comes when trying to trap the REMOTE_USER env variable
>when these users access our perl scripts. REMOTE_USER is blank when we run a
>.PL program but does show up when we run an .EXE out of the same directory.
We recently had the same problem.
Have you got *both* the script and the html page calling the script
password protected?
---
Chris (Mobiles, Watford) http://www.mobiles.co.uk
+--------------------------------------------------------------------------+
|Orange TalkAhead: Phone, Connection & 12 months line rental just 129.99ukp|
| Contact: 01923-804444 Mobile: 07970-804444 & 24hr Fax: 01923-805555 |
+--------------------------------------------------------------------------+
...... New Shop Now Open: 346-348 St Albans Rd, Watford, WD2 5PQ ......
------------------------------
Date: Sun, 13 Sep 1998 09:34:27 -0400
From: Chris Lambrou <cglcomputer@earthlink.com>
Subject: Re: Retrieve file from PC using LWP::UserAgent?
Message-Id: <35FBC9E3.2DC4CAD7@earthlink.com>
Vince,
I think it would be easier to retrieve a file from a local file system using
HTTP upload as implemented by Netscape Navigator 3.0 or later.
See http://www.scriptsearch.com/pages/l9c3c20.shtml for examples
HTH,
Chris.
------------------------------
Date: Sun, 13 Sep 1998 16:53:08 +0200
From: "Mattias Kristoffersen" <mattias@mjolby.nu>
Subject: Search textfile?
Message-Id: <6tglj8$fvs$1@zingo.tninet.se>
I have a text file, like this:
text1
text2
text3
text1
text3
And now I want to do a search (number of tex1 lines for example) and count
the hits
And is it more difficult if the text file looks like this
text1 text 1a text1b
text 2 text 2a text2b
text 3 text 3a text3b
Now I only want to do a search on the first word on every line the other
words should be ignored.
Help me please!
/Mattias
------------------------------
Date: Sun, 13 Sep 1998 15:54:43 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Search textfile?
Message-Id: <35FBEC43.4A6DC632@shaw.wave.ca>
[posted & mailed]
Mattias Kristoffersen wrote:
>
> I have a text file, like this:
> text1
> text2
> text3
> text1
> text3
> And now I want to do a search (number of tex1 lines for example) and
> count the hits
> And is it more difficult if the text file looks like this
> text1 text 1a text1b
> text 2 text 2a text2b
> text 3 text 3a text3b
> Now I only want to do a search on the first word on every line the
> other words should be ignored.
> Help me please!
It might have helped if you posted the code that worked for the simple
case. Something as simple as changing one line of it would probably
help.
Here's one line that should work. There are many others.
perl -lane '$cnt++ if $F[0] eq 'text1';END{ print "$cnt\n" }'
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Sat, 12 Sep 1998 03:13:57 GMT
From: pynq@midway.uchicago.edu (Jeremy Mathers)
Subject: Seeking Perl program to transfer files between machines (sort of like TFTP)
Message-Id: <Ez5IB9.C6E@midway.uchicago.edu>
I frequently have the need to transfer files between two Unix machines which
are side by side - i.e., such that using FTP is too much bother. I want to
just type something on each machine and have the file get transfered. So, I
wrote a little program in Perl that does exactly this, using NETCAT to do
the actual TCPIP transmission (just out of laziness). The program works
"pretty well" - which is to say, as long as you don't push it too hard.
I'd like to rewrite it to use Perl to do the actual network stuff - and I
have written socket level Perl in the past, so I can't imagine it will be
that difficult. However, and this is the point, in the spirit of
"Don't reinvent the wheel", I'd like to know if there is already an
off-the-shelf solution for this.
I did do a CPAN search - and didn't find what I was looking for. Please
note that I'm not interested in an "almost" solution - I've already got that.
I just want to know if there is a full solution to this out there. Thanks.
************************************************************************
I just <LOVE> water sports!
Our teachers are complete pros!
Jamilia and I actually synchronized our strokes.
We did the whole length of the pool on our backs.
Girl Scout camp is the greatest.
- From the back of the box of Tagalongs (in 1994!)
- (C) 1992, Girl Scouts of the U.S.A.
- Originally seen in Ted Frank's .sig in AFU
- Later seen gracing the pages of Spy Magazine.
- pynq@quads.uchicago.edu, who is still costing the net
hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer
------------------------------
Date: Sun, 13 Sep 1998 06:56:43 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Sorting Arrays of Hashes..
Message-Id: <6tg8db$ln6$1@earth.superlink.net>
Hello -
Alex Vandiver <vandiver@tiac.net> writes:
>Ye perl wizards, I, the clueless neophyte, have been pounding my head
>against what is probably a fairly simple/stupid mistake. Why the heck
>does the following code not sort an array of hashes?
>@s_data = sort {
> $b->{'WHATEVER'} <=> $a->{'WHATEVER'};
>} @data;
It does sort an array of hashes, in descending order by 'WHATEVER' key.
If you want ascending order (is that what's throwing you off?), you
need to switch $b and $a in your sort routine.
Complete working example:
#!/usr/local/bin/perl -w
my @data = ( { qw(WHATEVER 200) },
{ qw(WHATEVER 300) },
{ qw(WHATEVER 100) } );
my @s_data = sort { $b->{'WHATEVER'} <=> $a->{'WHATEVER'} } @data;
print $s_data[0]->{'WHATEVER'}; # prints 300 - highest value
David Black
dblack@saturn.superlink.net
------------------------------
Date: Sun, 13 Sep 1998 09:51:39 -0400
From: Chris Lambrou <cglcomputer@earthlink.com>
To: Alex Vandiver <vandiver@tiac.net>
Subject: Re: Sorting Arrays of Hashes..
Message-Id: <35FBCDEB.6EBF8841@earthlink.com>
Alex,
"<=>" is used for sorting numeric values, but for text you need "cmp":
@s_data = sort {$b->{WHATEVER} cmp $a->{WHATEVER}} @data;
HTH
Alex Vandiver wrote:
> Ye perl wizards, I, the clueless neophyte, have been pounding my head
> against what is probably a fairly simple/stupid mistake. Why the heck
> does the following code not sort an array of hashes?
> @s_data = sort {
> $b->{'WHATEVER'} <=> $a->{'WHATEVER'};
> } @data;
>
> Thanks..
> --
>
> Of all the things I've lost..
> ..I miss my mind the most..
------------------------------
Date: Sun, 13 Sep 1998 12:36:15 +0200
From: "Ekenberg" <joreb@algonet.se>
Subject: Suidperl is obstructed, but by what?
Message-Id: <6tg77s$9vm$1@cubacola.tninet.se>
I'm writing some scripts that need to be run as SUID.
It's done on a Linux system which doesn't honor the setuid-bit for
Perl-scripts, but only on binaries like a.out, etc. So far I've been using a
simple C-wrapper, but that's not really what I want.
In perlsec it says:
"Perl can emulate the setuid and setgid mechanism when it notices the
otherwise useless setuid/gid bits on Perl scripts. It does this via a
special executable called suidperl that is automatically invoked for you if
it's needed."
My problem is that suidperl doesn't seem to be "automatically invoked" for
me when I need it!
There is no error message when I try to run scripts with the setuid-bit set,
but it is simply ignored and the scripts are run as usual.
Perl version is 5.004_03
Suidperl is installed in the same directory as Perl itself, and made
executable.
What might be hindering suidperl from functioning correctly?
Thanks for helping me out!
/Johan Ekenberg
------------------------------
Date: Sun, 13 Sep 1998 11:34:57 GMT
From: Garry Williams <garry@america.net>
Subject: Re: Suidperl is obstructed, but by what?
Message-Id: <35FBAE28.7B2CB333@america.net>
Ekenberg wrote:
>
> I'm writing some scripts that need to be run as SUID.
> It's done on a Linux system which doesn't honor the setuid-bit for
> Perl-scripts, but only on binaries like a.out, etc. So far I've been using a
> simple C-wrapper, but that's not really what I want.
>
> In perlsec it says:
> "Perl can emulate the setuid and setgid mechanism when it notices the
> otherwise useless setuid/gid bits on Perl scripts. It does this via a
> special executable called suidperl that is automatically invoked for you if
> it's needed."
>
> My problem is that suidperl doesn't seem to be "automatically invoked" for
> me when I need it!
>
> There is no error message when I try to run scripts with the setuid-bit set,
> but it is simply ignored and the scripts are run as usual.
>
> Perl version is 5.004_03
> Suidperl is installed in the same directory as Perl itself, and made
> executable.
Shouldn't it be setuid root, as well?
-Garry Williams
> What might be hindering suidperl from functioning correctly?
>
> Thanks for helping me out!
>
> /Johan Ekenberg
------------------------------
Date: Sun, 13 Sep 1998 12:18:47 GMT
From: NOSPAMdelouw@bigfoot.com (Luc de Louw)
Subject: Very slow cgi-bin execution
Message-Id: <35fbb800.150880376@news.internetplus.ch>
Hi there!
I'm wordering, that the execution of a small perl script is very slow.
Is it possible to speed up with some settings?
My machine is running Linux 2.0.34
Tks for any help
Luc de Louw
------------------------------
Date: 13 Sep 1998 13:03:04 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Very slow cgi-bin execution
Message-Id: <6tgfq8$cp9@news-central.tiac.net>
In article <35fbb800.150880376@news.internetplus.ch>,
Luc de Louw <NOSPAMdelouw@bigfoot.com> wrote:
>Hi there!
>
>I'm wordering, that the execution of a small perl script is very slow.
>Is it possible to speed up with some settings?
>
>My machine is running Linux 2.0.34
What is the script doing? It's possible to write small programs which
will consume lots of time.
If the script runs fast enough on a data set when run from the command
line, but seems slow when used over the web then you might want to
investigate mod_perl. Mod_perl is an apache module which builds a perl
interpreter into the web server and can cache the compiled bytecode of
perl scripts it runs. Check out http://perl.apache.org for more details.
If the program just runs slowly then you might benefit from reconsidering
your design.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Sun, 13 Sep 1998 16:10:07 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Very slow cgi-bin execution
Message-Id: <Ez8Cwv.HI7@world.std.com>
NOSPAMdelouw@bigfoot.com (Luc de Louw) writes:
>I'm wordering, that the execution of a small perl script is very slow.
>Is it possible to speed up with some settings?
There are all sorts of reasons why a script may be slow. And almost
every reason has a different solution.
Some solutions are:
CPU/memory/IO upgrade
mod_perl
algorithm redesign
rewrite in something that can compile to machine language.
Of these solutions, the only one that could deal with perl may be
"algorithm redesign" one. Since you say it is a short script, why not
post it here and let a bunch of people take a look at it and make
suggestions.
--
Andrew Langmead
------------------------------
Date: Sun, 13 Sep 1998 08:14:09 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Why does this sort work in Dos but not in Unix?
Message-Id: <6tgcuh$1s7$1@earth.superlink.net>
Hello -
kevinslew@my-dejanews.com writes:
>I'm trying to sort an array of hashes. It runs fine as a dos script but
>doesn't change anything when running as a cgi on unix. Can anyone help?
>$results[0]{rank}=50;
>$results[0]{name}="Uncle";
>$results[1]{rank}=70;
>$results[1]{name}="Aunt";
>$results[2]{rank}=30;
>$results[2]{name}="Brother";
>print "Before\n";
>for $i (0..$#results) {
> print "$results[$i]{rank} $results[$i]{name}\n";
>}
>@newlist = sort {$a{rank} <=> $b{rank}} @results;
>print "After\n";
>for $i (0..$#newlist) {
> print "$newlist[$i]{rank} $newlist[$i]{name}\n";
>}
I can't answer the DOS part, only the Perl part.
@results is an array of hash references. Therefore, $a and $b
in the sort routine are hash references. Therefore, to get at
their values, you have to dereference them:
sort { $a->{rank} <=> $b->{rank} }
In your version, you're assuming that there are hashes called
%a and %b, which there aren't.
This is a good example of the usefulness of use strict even in
small-scale scripting. You would have gotten nailed all over the
place.
Here's a working version which should do what it's supposed to do on
any Perl platform (give or take the #! wording):
#!/usr/local/bin/perl -w
use strict;
# I'm one of these map() junkies....
my @results = map { {'rank', $_->[0], 'name', $_->[1]} }
([50, 'Uncle'], [70, 'Aunt'], [30, 'Brother']);
print "Before\n";
printres(\@results);
my @newlist = sort { $a->{rank} <=> $b->{rank} } @results;
print "\nAfter\n";
printres(\@newlist);
sub printres {
my $r = shift;
print map "$r->[$_]{rank}\t$r->[$_]{name}\n", (0..$#{$r});
}
__END__
David Black
dblack@saturn.superlink.net
------------------------------
Date: 13 Sep 1998 14:52:00 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: {{{ Programmer Needed... }}}
Message-Id: <u7lz8p1bz.fsf@jimbosntserver.soundimages.co.uk>
"Harley James - Image, Inc." <icorp@erols.com> writes:
>
> Programmer Needed...
>
> My company is looking to employ the services of a seasoned cgi programmer
> who can program for an apache server using perl.
Have you been living in a hole? Your post is in the wrong
group. Please avoid this crap in future. Please. Show some respect for
USENET convention.
Should you need any evidence, search on job* on DejaNews. You will
find a recent thread regarding posts such as yours. Please refrain.
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3704
**************************************