[13663] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1073 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 15:32:28 1999

Date: Fri, 15 Oct 1999 12:32:11 -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: <940015929-v9-i1073@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Oct 1999     Volume: 9 Number: 1073

Today's topics:
        Perl performance problem - change the readsize ? <prakash.prabhu@citicorp.com>
    Re: Perl performance problem - change the readsize ? <makkulka@cisco.com>
    Re: Perl performance problem - change the readsize ? <gellyfish@gellyfish.com>
    Re: Perl performance problem - change the readsize ? (Larry Rosler)
    Re: Perl performance problem - change the readsize ? <gellyfish@gellyfish.com>
        Perl Pics <moyerfamily@kscable.com>
    Re: Perl Pics (Martien Verbruggen)
        perl problem <dan.ho@pacific.net.sg>
    Re: perl problem (Abigail)
    Re: perl problem <cassell@mail.cor.epa.gov>
        Perl Processing <dontspamaua999@dontspamsocal.rr.com>
    Re: Perl Processing <newsposter@cthulhu.demon.nl>
    Re: Perl Processing (Clinton Pierce)
    Re: Perl Processing <dchristensen@california.com>
        Perl SMTP problems - simplicity turned to complexity [p <firstnamefirstletterlastnameANTISPAM@ANTISPAMnovell.com>
        Perl syntax question elitt@my-deja.com
    Re: Perl syntax question <theglauber@my-deja.com>
    Re: Perl syntax question (Tad McClellan)
    Re: Perl syntax question (Martien Verbruggen)
        perl wrapper scripts of executables with sticky executa (Eric Dew)
    Re: perl wrapper scripts of executables with sticky exe <rootbeer@redcat.com>
    Re: perl wrapper scripts of executables with sticky exe (Eric Dew)
        Perl4->Perl5 Migration <dwb1@home.com>
    Re: Perl4->Perl5 Migration (Tad McClellan)
        Perlbuilder from Solutionsoft <nospam-dbown@sequent.com>
        PID Question <joseph.t.primanti@lmco.com>
    Re: PID Question <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 13 Oct 1999 11:56:49 GMT
From: Prakash Prabhu <prakash.prabhu@citicorp.com>
Subject: Perl performance problem - change the readsize ?
Message-Id: <7u1s1r$hkg$1@nnrp1.deja.com>

Hi,
  I have written a program that has to read all the lines
in a file and check a particular field in each line. This is a 2.8 GB
file on DEC Alpha 4100 machine (Unix). While AWK does this in 6 minutes
Perl is taking twice that time. I can see that AWK is doing read from
the hard disk at 1400 kbps while Perl does at 700 kbps. This looks like
the cause of the delay in Perl.
  Is there any way, I can increase the I/O rate in Perl ?

--
Thank You,

Regards,
Prakash Prabhu


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 13 Oct 1999 11:34:09 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Perl performance problem - change the readsize ?
Message-Id: <3804D0A1.4099BC46@cisco.com>

{ Prakash Prabhu wrote:

>  I can see that AWK is doing read from
> the hard disk at 1400 kbps while Perl does at 700 kbps.

How did you come up with these figures? It seems as if
the disk reads are spaced out in Perl because it is spending
more time in processing the lines read.
Can you post the code.
--



------------------------------

Date: 13 Oct 1999 21:55:10 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl performance problem - change the readsize ?
Message-Id: <7u2v3u$g2$1@gellyfish.btinternet.com>

On Wed, 13 Oct 1999 11:56:49 GMT Prakash Prabhu wrote:
> Hi,
>   I have written a program that has to read all the lines
> in a file and check a particular field in each line. This is a 2.8 GB
> file on DEC Alpha 4100 machine (Unix). While AWK does this in 6 minutes
> Perl is taking twice that time. I can see that AWK is doing read from
> the hard disk at 1400 kbps while Perl does at 700 kbps. This looks like
> the cause of the delay in Perl.

I dont see awk as being twice as fast :

gellyfish:/var/spool/mail # time perl -ne '1;' jns

real    0m4.415s
user    0m2.050s
sys     0m0.270s
gellyfish:/var/spool/mail # time awk '{}' jns

real    0m3.824s
user    0m1.150s
sys     0m0.170s
gellyfish:/var/spool/mail # ls -l jns
-rw-------   1 jns      dialout  10042061 Oct 13 19:17 jns

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


------------------------------

Date: Wed, 13 Oct 1999 15:30:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl performance problem - change the readsize ?
Message-Id: <MPG.126ea7e77466286a98a08c@nntp.hpl.hp.com>

In article <7u2v3u$g2$1@gellyfish.btinternet.com> on 13 Oct 1999 
21:55:10 -0000, Jonathan Stowe <gellyfish@gellyfish.com> says...

 ...

> I dont see awk as being twice as fast :
> 
> gellyfish:/var/spool/mail # time perl -ne '1;' jns
> 
> real    0m4.415s
> user    0m2.050s
> sys     0m0.270s
> gellyfish:/var/spool/mail # time awk '{}' jns
> 
> real    0m3.824s
> user    0m1.150s
> sys     0m0.170s
> gellyfish:/var/spool/mail # ls -l jns
> -rw-------   1 jns      dialout  10042061 Oct 13 19:17 jns

2.05 + 0.27 = 2.32

1.15 + 0.17 = 1.32

2.32 / 1.32 = 1.76

Damn near twice as fast, I would say!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 14 Oct 1999 20:35:51 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl performance problem - change the readsize ?
Message-Id: <7u5er7$1c3$1@gellyfish.btinternet.com>

On Wed, 13 Oct 1999 15:30:38 -0700 Larry Rosler wrote:
> In article <7u2v3u$g2$1@gellyfish.btinternet.com> on 13 Oct 1999 
> 21:55:10 -0000, Jonathan Stowe <gellyfish@gellyfish.com> says...
> 
> ...
> 
>> I dont see awk as being twice as fast :
>> 
>> gellyfish:/var/spool/mail # time perl -ne '1;' jns
>> 
>> real    0m4.415s
>> user    0m2.050s
>> sys     0m0.270s
>> gellyfish:/var/spool/mail # time awk '{}' jns
>> 
>> real    0m3.824s
>> user    0m1.150s
>> sys     0m0.170s
>> gellyfish:/var/spool/mail # ls -l jns
>> -rw-------   1 jns      dialout  10042061 Oct 13 19:17 jns
> 
> 2.05 + 0.27 = 2.32
> 
> 1.15 + 0.17 = 1.32
> 
> 2.32 / 1.32 = 1.76
> 
> Damn near twice as fast, I would say!
> 

Hmm, I was looking at the 'real' time because that was the slant the
original poster was taking ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


------------------------------

Date: Thu, 14 Oct 1999 21:09:41 GMT
From: "Moyer Family" <moyerfamily@kscable.com>
Subject: Perl Pics
Message-Id: <pErN3.6904$OH2.85521@typhoon2.kc.rr.com>

I have seen It done but don't know how to make pictures with Perl.  I made a
site password protected by just having the whole thing inside of one .pl .
This works just fine for everything except pictures because it dynamicaly
creats the text(can't be looked at without password) but pictures have to be
stored(and therefore viewed by anyone(these have important info in them).  I
have seen scripts that require access directly to a Perl server but I am a
tightwad and only use the free services( i.e. Webjump, only allows FTP
upload, not server modification).  Any Ideas?  Please answer to
bozodaclown2001@hotmail.com because I don't check newsgroups often.  Thanks,
Keith




------------------------------

Date: 15 Oct 1999 11:32:25 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Perl Pics
Message-Id: <slrn80e47n.qf9.mgjv@wobbie.heliotrope.home>

[Followups set]

On Thu, 14 Oct 1999 21:09:41 GMT,
	Moyer Family <moyerfamily@kscable.com> wrote:
> I have seen It done but don't know how to make pictures with Perl.  I made a

With the GD modules, or PerlMagick, or with one of the higher level
modules that are out there, or by studying the format that you want to
write, and writing the correct set of bytes to a file or stream. Maybe
some other ways.

> site password protected by just having the whole thing inside of one .pl .

*parse*parse*parse* I don't get that bit.

> This works just fine for everything except pictures because it dynamicaly

Huh? Why not? is your perl script doing the protecting? Why don't you
let your web server do that? And if you can't, then why don't you let
your perl script produce the pictures as well?

> creats the text(can't be looked at without password) but pictures have to be
> stored(and therefore viewed by anyone(these have important info in them).  I

No they don't. You can make them on the fly. And if you want to store
them, you can store them outside of the Document tree, and let your
script.... I'm stopping here. This has nothing at all to do with Perl.
I'm still assuming this is a CGI program on a web server, so please
ask this question in a group about CGI.

> have seen scripts that require access directly to a Perl server but I am a

A Perl Server? What's that?

> tightwad and only use the free services( i.e. Webjump, only allows FTP

Indeed.

> upload, not server modification).  Any Ideas?  Please answer to
> bozodaclown2001@hotmail.com because I don't check newsgroups often.  Thanks,
> Keith

It gets better all the time. You're too lazy to learn the language or
at least try something. You're too lazy to try to make sure that
you're asking the question in the right place. You're too lazy to even
present your problem in a clear way. 

And now you make it clear that you're too bloody lazy to even come
back and read the answers?

How rude

Martien

PS. Yes, i am cranky. This sort of tripe does that to me.

PPS. *plonk to this one*
-- 
Martien Verbruggen              | 
Interactive Media Division      | Failure is not an option. It comes bundled
Commercial Dynamics Pty. Ltd.   | with your Microsoft product.
NSW, Australia                  | 


------------------------------

Date: Wed, 13 Oct 1999 14:16:07 +0800
From: Daniel <dan.ho@pacific.net.sg>
Subject: perl problem
Message-Id: <380423A7.B5F866E@pacific.net.sg>

hi!
have a problem
can i log my form fields into a logfile in xls format?? with different
fields separated by delimiters?
tried in txt but need to do it in a xls format.

Daniel



------------------------------

Date: 13 Oct 1999 14:59:07 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: perl problem
Message-Id: <slrn809p3r.nk2.abigail@alexandra.delanet.com>

Daniel (dan.ho@pacific.net.sg) wrote on MMCCXXXIV September MCMXCIII in
<URL:news:380423A7.B5F866E@pacific.net.sg>:
|| hi!
|| have a problem
|| can i log my form fields into a logfile in xls format?? with different
|| fields separated by delimiters?
|| tried in txt but need to do it in a xls format.



Well, yes. 

      print LOG $string_in_xls_format;



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Wed, 13 Oct 1999 14:51:24 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: perl problem
Message-Id: <3804FEDC.41EAF299@mail.cor.epa.gov>

Daniel wrote:
> 
> hi!
> have a problem
> can i log my form fields into a logfile in xls format?? with different
> fields separated by delimiters?
> tried in txt but need to do it in a xls format.

You can create an Excel workbook using the win32::OLE module.
See the docs which come with ActiveState Perl.  There's a whole
section on OLE Automation in the ActivePerl [win32] FAQ.

Or you could just create a CSV [comma-separated values] file
and then read that directly into Excel...

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Thu, 14 Oct 1999 09:20:22 -0700
From: Bernie Aua <dontspamaua999@dontspamsocal.rr.com>
Subject: Perl Processing
Message-Id: <380602C6.4FD0DED6@dontspamsocal.rr.com>

I've got a web server on a Unix system located at a hosting service that
uses Apache. I'm running a PERL cgi script that fetches a web document,
does some content massaging, then returns the invigorated contents. The
script works well, however, there is an issue I face.

I am under the impression that when a PERL cgi script is called (in this
case by a client request that comes in), an instance of the script is
run. Should there be multiple client requests, multiple instances of the
script will should run which are all independent.

But in the situation where multiple client requests come in at the same
time or close to the same time, let's say within a second or two, the
instances of each script don't always start close to the same time, and
the processing time changes. Let's say it takes one client request 2
seconds to fulfill. If 2 requests come in together, the 2 instances
start at the same time, but the processing time doubles. If 3 requests
come in together, the third instance does not start until the first 2
are completed. Extending that to 6 requests, it appears 2 instances are
started and processed. Once they are completed, the next 2 are processed
and once completed, the next 2... So it seems requests are getting
shuffled into a first come first serve queue and I get a bottleneck. I
can see processing time go up, but not double. Obviously, the Perl
interpreter needs to load each time the script is called.

What I need is multiple simultaneous requests to be processed at the
same time with slightly increased processing time. Is there something I
can do to achieve this? I've heard of mod_perl where the interpreter and
any scripts are loaded once into memory, but since the server box is
hosted and implementing mod_perl requires recompiling the server, this
is not a good option for me, plus I may need to install the script on an
NT system later on. In addition, I don't know if there may still be an
issue with the processing time.

Any help will be greatly appreciated.




------------------------------

Date: 14 Oct 1999 17:42:36 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Perl Processing
Message-Id: <7u54mc$5t3$1@internal-news.uu.net>

Bernie Aua <dontspamaua999@dontspamsocal.rr.com> wrote:

> What I need is multiple simultaneous requests to be processed at the
> same time with slightly increased processing time. Is there something I
> can do to achieve this?

Yes, get a machine with multiple processors.

Erik



------------------------------

Date: Thu, 14 Oct 1999 18:02:38 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Perl Processing
Message-Id: <3806169c.781347678@news.ford.com>

On Thu, 14 Oct 1999 09:20:22 -0700, Bernie Aua
<dontspamaua999@dontspamsocal.rr.com> wrote:

Use a real E-Mail address, next time.  This Isn't Nice.
use constant BAD_MOOD => 1;

>I am under the impression that when a PERL cgi script is called (in this
>case by a client request that comes in), an instance of the script is
>run. Should there be multiple client requests, multiple instances of the
>script will should run which are all independent.

Yup.  Welcome to the Web.

>Obviously, the Perl
>interpreter needs to load each time the script is called.

Umm...well, yeah.  That's the whole point.

>What I need is multiple simultaneous requests to be processed at the
>same time with slightly increased processing time. Is there something I
>can do to achieve this? 

The phrase "slightly increased" is just so...vague.  Do you have a
particular "number of instances" x "processing time" curve you'd like to
hit?  Trying to do that on a multitasking system is folly.  Remember, you
aren't the only thing running on the machine.  If you use too much CPU,
and the web hosting company complains, see the last paragraph of this
posting and get a new hosting company.

If you ARE the only thing running on the machine, what do you care how
loaded the CPU gets?  Run some stress tests and see how badly the CGI and
Perl startup time affects the machine.  This is how everyone else does it.

>I've heard of mod_perl where the interpreter and
>any scripts are loaded once into memory, but since the server box is
>hosted and implementing mod_perl requires recompiling the server, this
>is not a good option for me, plus I may need to install the script on an
>NT system later on. In addition, I don't know if there may still be an
>issue with the processing time.

Jeez, the perfect option is mod_perl, but if you can't do that you want
another option?  The mod_perl module does JUST WHAT YOU'VE ASKED FOR, and
doesn't require you to do anything special with your code if you've done
things right.  Also, if you write the code correctly, it will just work on
NT, with or without mod_perl.

Just write the CGI, do it correctly.  Take advantage of mod_perl if you
can, deal with CPU usage if you can't.  If you don't like the startup time
for Perl, and can't use mod_perl write your CGI programs in C.

-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


------------------------------

Date: Thu, 14 Oct 1999 12:56:23 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: Perl Processing
Message-Id: <38063285_3@news5.newsfeeds.com>

Bernie:

It sounds like a semaphore (file lock?) is being held for a long
time (?).

Posting code would be helpful.

--
David Christensen
dchristensen@california.com



Bernie Aua wrote in message
<380602C6.4FD0DED6@dontspamsocal.rr.com>...
>I've got a web server on a Unix system located at a hosting
service that
>uses Apache. I'm running a PERL cgi script that fetches a web
document,
>does some content massaging, then returns the invigorated
contents. The
>script works well, however, there is an issue I face.
>
>I am under the impression that when a PERL cgi script is called
(in this
>case by a client request that comes in), an instance of the script
is
>run. Should there be multiple client requests, multiple instances
of the
>script will should run which are all independent.
>
>But in the situation where multiple client requests come in at the
same
>time or close to the same time, let's say within a second or two,
the
>instances of each script don't always start close to the same
time, and
>the processing time changes. Let's say it takes one client request
2
>seconds to fulfill. If 2 requests come in together, the 2
instances
>start at the same time, but the processing time doubles. If 3
requests
>come in together, the third instance does not start until the
first 2
>are completed. Extending that to 6 requests, it appears 2
instances are
>started and processed. Once they are completed, the next 2 are
processed
>and once completed, the next 2... So it seems requests are getting
>shuffled into a first come first serve queue and I get a
bottleneck. I
>can see processing time go up, but not double. Obviously, the Perl
>interpreter needs to load each time the script is called.
>
>What I need is multiple simultaneous requests to be processed at
the
>same time with slightly increased processing time. Is there
something I
>can do to achieve this? I've heard of mod_perl where the
interpreter and
>any scripts are loaded once into memory, but since the server box
is
>hosted and implementing mod_perl requires recompiling the server,
this
>is not a good option for me, plus I may need to install the script
on an
>NT system later on. In addition, I don't know if there may still
be an
>issue with the processing time.
>
>Any help will be greatly appreciated.
>
>




  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Thu, 14 Oct 1999 16:33:20 -0600
From: "Jeff Pitman" <firstnamefirstletterlastnameANTISPAM@ANTISPAMnovell.com>
Subject: Perl SMTP problems - simplicity turned to complexity [posted from novell.netscape.enterpriseserver]
Message-Id: <7u5lnr$705$3@acs2.byu.edu>

--Intro--

I've been having problems with the sendmail.pl script lately because I'm
using the code in a $SIG{"__DIE__"} handler.  The purpose is this, if
something goes wrong with my scripts while I'm gone, I want a log of it
*and* I want email notification of what happened.  So, I said, "Ok, let's
take a look at ActiveState's Win32 dist of Perl".   I went and installed
some modules from CPAN onto Win NT (since that dist has the PPM, which makes
it nice to update perl mods)  The most interesting one I ran into was
Net::SMTP.  This module let's you instantiate an object that you can mail
messages through.   Makes it a little easier since you don't have to mess
with the sockets.  And the code looks clean.

--The Test--

Well, since Novonyx Perl doesn't have PPM or CPAN.pm, I just copied what I
had from the lib/ directory on my NT machine over to the SYS:perl/lib
directory on the NetWare server.  Basically it was an entire Net/ directory
full of modules not included with the NES release.  So, I went through with
the Net::SMTP doc (automatically generated by PPM into HTML and CHM [windows
help format], courtesy of ActiveState), and copied out a simple example:
    use Net::SMTP;
    $smtp = Net::SMTP->new('mailhost');
    $smtp->mail($ENV{USER});
    $smtp->to('postmaster');
    $smtp->data();
    $smtp->datasend("To: postmaster\n");
    $smtp->datasend("\n");
    $smtp->datasend("A simple test message\n");
    $smtp->dataend();
    $smtp->quit;
Of course, I changed mailhost, $ENV{USER}, postmaster, to reflect what I
wanted. Then I ran it...

--Locked Script | Weird Server Errors--

At object creation the server would spit out errors:
SERVER-5.00-1948: Unable to find load file /COM/HOST
SERVER-5.00-1948: Unable to find load file (HOSTNAME)
SERVER-5.00-1948: Unable to find load file UNAME
(BTW, I was running it both at the console and as a CGI script at this
point.)  I was getting very frustrated that the script was locking up.  So,
I investigated the above errors systematically.  After opening the SMTP.pm,
I threw prints all over the code, including on the use lines.  To make a
long story short, I narrowed it down to Net::Domain.   Inside Net::Domain,
it checks if the OS is MSWin32, if not it does a bunch of  Unix-specific
stuff.  That's why I was getting the above errors.  So, on line 30 or so,  I
changed to:
        if( $^O eq 'MSWin32' || $^O eq 'NetWare' )
And it fixed my problems, right?

--The Saga Continues--

Well, I got rid of the SERVER errors, *but*, the script locks up and gives
an error.  The error is as follows:
Goto undefined subroutine &AutoLoader::AUTOLOAD at
sys:\perl\lib/IO/Handle.pm line 245.
'DOH! What the crap is this?'  Well, Handle.pm creates a "dynamic" handle to
a specific function found in derived classes of IO::Handle.  So, I inspected
Handle and found that the AutoLoading dynamic:) subroutine is supposed to be
Net::SMTP::senddata.  ????? Ok, I looked in SMTP.pm again, there's isn't an
explicit declaration of senddata or datasend, hence the dynamic loading
concept I guess.

Next I put in my own subroutine named senddata, that printed a debug
statement.  By doing that, it bypasses the Goto undefined subroutine error.
*But*, it still locks up.

--Temporary Dauntedness--

Well, I'm daunted currently, and would like some help.  I kinda targeted
tomorrow to get this thing done, but, it's not looking pretty.  I know there
are 1.2 million other ways to mail things, I just would like to say:  "Wow,
I updated Perl on NetWare via CPAN [kinda] and when I ran an example script,
it worked."  If anyone has an idea, about Net::SMTP, please help.

Thanks
Jeff










------------------------------

Date: Wed, 13 Oct 1999 20:03:06 GMT
From: elitt@my-deja.com
Subject: Perl syntax question
Message-Id: <7u2ohg$8ff$1@nnrp1.deja.com>

I have some code that does not work and I am trying to figure it out.
I am not familiar with the syntax of the following code snippet.

foreach $fld (@flds){
     $uniq_vals{$fld}{$data{$fld}}++;
}

"uniq_vals" is an associative array.
"flds" an array that contains 5 entries.
"data" is an assoiative array which contains 11 pairs of data.

My guess is that this is a multi dimensional array, but I don't
understand how it works exactly.  Especially the ++, what does this
increment?

Any help would be great.


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 13 Oct 1999 21:09:04 GMT
From: The Glauber <theglauber@my-deja.com>
Subject: Re: Perl syntax question
Message-Id: <7u2sd4$bah$1@nnrp1.deja.com>

In article <7u2ohg$8ff$1@nnrp1.deja.com>,
  elitt@my-deja.com wrote:
> I have some code that does not work and I am trying to figure it out.
> I am not familiar with the syntax of the following code snippet.
>
> foreach $fld (@flds){
>      $uniq_vals{$fld}{$data{$fld}}++;
> }

This kind of code is used to select unique values from a bunch of data.
I'm going to say "hash" instead of "associative array" to save
electrons, but it's the same thing, OK?

%uniq_vals is a hash
%data is another hash

For each element in the @flds array,
    (A) look it up in the %data array
    (B) look it up again in the %uniq_vals array. Treat that as a
reference to another hash (if it doesn't already exist, it's created).
This is an anonymous hash, but let's call it %Bob just so we know who
we are talking about.
    (C) look up the result of (A) in the %Bob hash and increment it.
Any value that is not there yet will be inserted as 1 (since the
undefined value converts to a number zero before being incremented).


(A) is probably doing some sort of "translation" (e.g.: "BL" -->
"BLUE").

(C) is counting how many times you saw each code. The first time you
see a code, the hash value will be undefined. However, when you
increment it, that undefined value is converted to a number zero, which
increments to 1.


I don't really like this code. I'm not sure why it was done this way,
but i'm pretty sure it could have been done in a simpler way. I'm not
going to volunteer to rewrite it, because i don't know what the code is
trying to achieve.
hth...


glauber


--
Glauber Ribeiro
theglauber@my-deja.com
"Opinions stated are my own and not representative of Experian"


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 13 Oct 1999 18:09:46 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl syntax question
Message-Id: <avv2u7.5u1.ln@magna.metronet.com>

elitt@my-deja.com wrote:
: I have some code that does not work and I am trying to figure it out.
: I am not familiar with the syntax of the following code snippet.

: foreach $fld (@flds){
:      $uniq_vals{$fld}{$data{$fld}}++;
: }

: "uniq_vals" is an associative array.


   It used to be a "associative array", but now it is called a "hash".

   We are much too lazy and impatient to say that many syllables
   all the time when one syllable will do it.  :-)

   And saving time by using Perl is what makes us all feel
   self-satisfied (though perhaps subject to retribution).


: "flds" an array that contains 5 entries.
: "data" is an assoiative array which contains 11 pairs of data.


   ... and the elements of @flds are keys to the data in %data.

   So 6 of the pairs are not used in this code.


: My guess is that this is a multi dimensional array, 


   Yes. It is a Hash of Hashes (HoH).

   It is 2 levels "deep":  $uniq_vals{}{} references one of the
   scalar values.


: but I don't
: understand how it works exactly.  

   HoHs are covered in perldsc.pod (Data Structures Cookbook).

   $fld is the first hash key.

   $data{$fld} is the second hash key.

   $uniq_vals{$fld}{$data{$fld}} is the scalar that you get with
   those 2 keys.


: Especially the ++, what does this
: increment?


   It increments the scalar value in $uniq_vals{}{}.



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Thu, 14 Oct 1999 05:45:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl syntax question
Message-Id: <%5eN3.436$Bu4.8114@nsw.nnrp.telstra.net>

On Wed, 13 Oct 1999 18:09:46 -0400,
	Tad McClellan <tadmc@metronet.com> wrote:
> elitt@my-deja.com wrote:

> : "uniq_vals" is an associative array.
> 
> 
>    It used to be a "associative array", but now it is called a "hash".
> 
>    We are much too lazy and impatient to say that many syllables
>    all the time when one syllable will do it.  :-)
> 
>    And saving time by using Perl is what makes us all feel
>    self-satisfied (though perhaps subject to retribution).

And of course we're saving time because we no longer have to explain
that an associative array isn't an array. :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | In the fight between you and the world,
Commercial Dynamics Pty. Ltd.   | back the world - Franz Kafka
NSW, Australia                  | 


------------------------------

Date: 13 Oct 1999 18:48:09 GMT
From: edew@netcom.com (Eric Dew)
Subject: perl wrapper scripts of executables with sticky executable bit
Message-Id: <7u2k59$2t0@dfw-ixnews10.ix.netcom.com>

Hello,

I would like to write some perl scripts to wrap over some executables.
Also, I want to change the permission for that executable (say, co (checkout
in RCS :-)) to be rwsr--r-- so that only the owner of the utility can 
execute it.  This way, people MUST use the perl script and not use the
actual co command to do their work.

Apparently, I can't just set $ENV{"LOGNAME"} = "co owner" and then
run the command after that.  I believe I have to run `su "co owner"`;
first.  But su requires I input the password.

Any ideas on how to write perl scripts to wrap commands with sticky
executable bit?

Thanks,

EDEW


------------------------------

Date: Wed, 13 Oct 1999 14:45:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perl wrapper scripts of executables with sticky executable bit
Message-Id: <Pine.GSO.4.10.9910131441500.25558-100000@user2.teleport.com>

On 13 Oct 1999, Eric Dew wrote:

> I would like to write some perl scripts to wrap over some executables.
> Also, I want to change the permission for that executable (say, co
> (checkout in RCS :-)) to be rwsr--r-- so that only the owner of the
> utility can execute it.  This way, people MUST use the perl script and
> not use the actual co command to do their work.

I think you're mistaken (or I am). I think you want to change the RCS
utils to be mode 500 (or 700) so that they can be executed only by one
user, then make your wrapper run as that user. Does that do what you want?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 14 Oct 1999 00:31:27 GMT
From: edew@netcom.com (Eric Dew)
Subject: Re: perl wrapper scripts of executables with sticky executable bit
Message-Id: <7u388v$l9b@dfw-ixnews21.ix.netcom.com>

In article <Pine.GSO.4.10.9910131441500.25558-100000@user2.teleport.com>,
Tom Phoenix  <rootbeer@redcat.com> wrote:
>On 13 Oct 1999, Eric Dew wrote:
>
>> I would like to write some perl scripts to wrap over some executables.
>> Also, I want to change the permission for that executable (say, co
>> (checkout in RCS :-)) to be rwsr--r-- so that only the owner of the
>> utility can execute it.  This way, people MUST use the perl script and
>> not use the actual co command to do their work.
>
>I think you're mistaken (or I am). I think you want to change the RCS
>utils to be mode 500 (or 700) so that they can be executed only by one
>user, then make your wrapper run as that user. Does that do what you want?
>

Yes, that what I want to do.  I thought that's what I wrote above.  Basically,
co has permission rwxr-xr-x, so that anyone can use it.  I want to change its
permission to rwx------ (as you say), have a perl-based wrapper run as
the owner of co, and allow anyone to use the wrapper.

EDEW


------------------------------

Date: Thu, 14 Oct 1999 15:03:30 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Perl4->Perl5 Migration
Message-Id: <Pine.LNX.4.10.9910140948310.1492-100000@cc569157-a.warn1.mi.home.com>


Hello,

We are finally in the process of migrating a large number
of perl scripts from perl4 (oraperl), to perl5.  So far
there has not been any major issues for us to work through,
the first step has just been to get everything to WORK like
we expect it to, and it's gone pretty well.

The next step we plan to do is seriously cleanup the code
(total of 10 different programmers have worked on it, no
more then 2 at a time have ever worked together, so it's a
mess!), and convert the library files to modules, then
eventually we want to move to mod_perl.

I'm curious to hear anyone elses comments/experiences in
doing the same thing, i.e. things to watch out for, or very
good resources to check out.

I've read plenty about the things you have to do to get mod_perl
to work right for you, but not a lot about perl4->5 migration,
or converting large amounts of interdependant files to modules.

Can you believe that all this code was developed without -w?!?!!!

Dan.




------------------------------

Date: Thu, 14 Oct 1999 10:08:00 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl4->Perl5 Migration
Message-Id: <04o4u7.5o3.ln@magna.metronet.com>

Daniel W. Burke (dwb1@home.com) wrote:

: We are finally in the process of migrating a large number
: of perl scripts from perl4 (oraperl), to perl5.


: Can you believe that all this code was developed without -w?!?!!!


   So that is surely already on your list of things to fix.

   You should also get them all to work with "use strict".

   You should also get CGI programs to work with -T

   (though your company appears to be very unconcerned with
    security, since you are still using Perl 4. See www.cert.org
    for warnings about security issues with old perls...
   )


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 15 Oct 1999 14:56:39 GMT
From: "David Bown" <nospam-dbown@sequent.com>
Subject: Perlbuilder from Solutionsoft
Message-Id: <01bf171d$7b5ac560$da76549e@w-skefford.uk.sequent.com>

Just wondering if anyone had any comments - experience with the above
mentioned application?

Dave B
IBM Numa-Q


------------------------------

Date: Thu, 14 Oct 1999 17:01:01 -0600
From: "Primanti, Joseph T" <joseph.t.primanti@lmco.com>
Subject: PID Question
Message-Id: <380660AC.7BFD1771@lmco.com>

I am using ActiveState Perl -519. Since fork() does not work on NT I
need some advice. I have written a script that sends mail via smtp using
Sockets. If there is a network glitch or if the email server is down for
example and I am running this command:  recv(SMTP, $buffer, 1000, 0);
the script will hang forever waiting for a response that never comes. I
need to spawn the email script and if it does not return to the parent
process after 60 seconds for example then kill the process. Any advice??

Joe Primanti


------------------------------

Date: Thu, 14 Oct 1999 22:42:59 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: PID Question
Message-Id: <380694B3.84C9CBD8@rochester.rr.com>

"Primanti, Joseph T" wrote:
> 
> I am using ActiveState Perl -519. Since fork() does not work on NT I
> need some advice. I have written a script that sends mail via smtp using
> Sockets. If there is a network glitch or if the email server is down for
> example and I am running this command:  recv(SMTP, $buffer, 1000, 0);
> the script will hang forever waiting for a response that never comes. I
> need to spawn the email script and if it does not return to the parent
> process after 60 seconds for example then kill the process. Any advice??

Sure -- ditch NT, use Linux :-)

> 
> Joe Primanti
-- 
Bob Walton


------------------------------

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 1073
**************************************


home help back first fref pref prev next nref lref last post