[17004] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4416 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 24 03:08:35 2000

Date: Sun, 24 Sep 2000 00:05:09 -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: <969779108-v9-i4416@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 24 Sep 2000     Volume: 9 Number: 4416

Today's topics:
    Re: - For this type of use (see msg), should I favor Pe <bart.lateur@skynet.be>
    Re: - For this type of use (see msg), should I favor Pe <uri@sysarch.com>
    Re: - For this type of use (see msg), should I favor Pe (Tony L. Svanstrom)
    Re: - For this type of use (see msg), should I favor Pe <christopher_j@uswest.net>
    Re: - For this type of use (see msg), should I favor Pe (Martien Verbruggen)
    Re: Candidate for the top ten perl mistakes list <bart.lateur@skynet.be>
        convert from windows to linux <yosef_hacohen@yahoo.com>
    Re: convert from windows to linux <ddorward@hotmail.com>
    Re: Displaying form Data <Rom22ero@pharmacy.arizona.edu>
    Re: Displaying form Data (Abigail)
    Re: Displaying form Data <Rom22ero@pharmacy.arizona.edu>
    Re: Displaying form Data (Martien Verbruggen)
    Re: LWP and proxy <derek@ooc.com.au>
    Re: matching a date <derek@ooc.com.au>
    Re: multiple ties to a single DB_file (Tony L. Svanstrom)
        Newbie needs help with search and replace <neilw@SPAMidirect.com>
    Re: Newbie needs help with search and replace (Abigail)
        perl 5.6, Net::POP3, database files, and more <news@althepal.com>
        Perl IPC - Looking for a suggestion <mcnuttj@nin.iats.missouri.edu>
    Re: Perl IPC - Looking for a suggestion <bwalton@rochester.rr.com>
        Perl2EXE worthwhile? <randy_734@my-deja.com>
        References and local (Abigail)
    Re: Testing file for directory: doesn't work <bwalton@rochester.rr.com>
    Re: The best tutorial? <bwalton@rochester.rr.com>
    Re: Time Zone conversion <noone@nospam.com>
    Re: variable -> constant? (Martien Verbruggen)
    Re: vertical text renderer <bwalton@rochester.rr.com>
    Re: vertical text renderer <godzilla@stomp.stomp.tokyo>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 24 Sep 2000 05:05:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <u62rss8qjtor4133frdg6b1sgpi4lrnivq@4ax.com>

Martien Verbruggen wrote:

>Starting new processes is almost a trivial cost on modern OS's.

You'll have a hard time convincing me, since my latest experience.

I have an old 486DX-2/66 with lots of RAM, on which I installed a recent
FreeBSD (Linux' more mature half brother), and Apache. I copied one of
my company's websites onto it, which is half static, half dynamic (Perl
plain CGI scipt). I can browse from my PC through the 10Mb network.

Response for the static pages is virtually immediate. Complex pages with
many, and large, images appear virtually instantly on screen. So for
that, the slow server is definitely still fast enough. But I do notice a
long delay, of up to several seconds, for even simple CGI scripts. The
script itself always finishes in a fraction of a second, so yes, Perl
itself is more than fast enough. Why the large difference in delay
between static and CGI? Well, though I could be wrong, the new proces is
the first thing that comes to my mind.

I have been thinking how such a server with noticable slowdown, even
with a load of one customer (me), is an ideal platform to experiment
with alternative forms of CGI-compatible scripting (e.g. fastCGI).

-- 
	Bart.


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

Date: Sun, 24 Sep 2000 05:33:32 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <x7r96abbgy.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> Response for the static pages is virtually immediate. Complex pages with
  BL> many, and large, images appear virtually instantly on screen. So for
  BL> that, the slow server is definitely still fast enough. But I do notice a
  BL> long delay, of up to several seconds, for even simple CGI scripts. The
  BL> script itself always finishes in a fraction of a second, so yes, Perl
  BL> itself is more than fast enough. Why the large difference in delay
  BL> between static and CGI? Well, though I could be wrong, the new proces is
  BL> the first thing that comes to my mind.

starting up perl itself is very slow and memory intensive. try using
fastcgi or speedy cgi and you will see a major improvement in speed.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sun, 24 Sep 2000 07:58:54 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <1ehgdvr.1nvwpdplyeq4yN%tony@svanstrom.com>

        [Followup-To: comp.infosystems.www.authoring.cgi]

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:

> On Sat, 23 Sep 2000 15:16:29 +0200,
>       Tony L. Svanstrom <tony@svanstrom.com> wrote:
> > Clay Irving <clay@panix.com> wrote:
> > 
> > > On Fri, 22 Sep 2000 23:25:30 -0400, Jon <vemba72@hotmail.com> wrote:
> > 
> > > >PS: The server admin told me he had to shut down several sites earlier
> > > >this year because of Perl scripts... too many hits, and every hit ran the
> > > >template-grabbing CGI.  He said sites that get less hits but use Perl tax
> > > >the server more than sites that get more hits but use PHP... somehow, PHP
> > > >opens and closes fewer files (that's how it was explained to me) so he's
> > > >strongly pushing for PHP.  Is this all just BS?
> > > 
> > > Sounds like BS.
> > 
> > Not really, with CGI you start a new process with each script, that
> > doesn't happen with PHP. [*]
> 
> Starting new processes is almost a trivial cost on modern OS's.

A lot of things are trivial when you look at it happening once, then
when you've got it happening 100 times within a second you start
noticing that it might not be so trivial after all.

> And there is nothing inherent in Perl that forces an OS to spawn a new
> proecess. CGI, yes. But not Perl. Don't perpetuate falsities that are
> stated in the original question, which was garbled and got many issues
> confused.

Which is why I wrote "with CGI".

> There are many ways to run Perl programs for web servers, not all of them
> are CGI. Even the ones that are can be made to behave better.

Which is why I said that it was too simplified, but considering that CGI
they way most people think of it is how you find it on most IPPs out
there, it's true enough for this discussion.

> That part of the discussion certainly doesn't belong on this group.

Followup-To's are clever lil things.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Sat, 23 Sep 2000 23:17:45 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <f0hz5.1324$b47.512248@news.uswest.net>


"Bart Lateur" <bart.lateur@skynet.be> wrote:
> Martien Verbruggen wrote:
>
> >Starting new processes is almost a trivial cost on modern OS's.
>
> You'll have a hard time convincing me, since my latest experience.
>
> I have an old 486DX-2/66 with lots of RAM, on which I installed a recent
> FreeBSD (Linux' more mature half brother), and Apache. I copied one of
> my company's websites onto it, which is half static, half dynamic (Perl
> plain CGI scipt). I can browse from my PC through the 10Mb network.

Oh puh-leaze, you're running a server on a 486 (a 66MHz no less)
and you're complaining about the speed?  Hmmm, lemme try to
troubleshoot where the speed drain might be.  It's either the
OS, Perl, Apache, the 10baseT network, or your funky old-ass
server hardware.  Any modern computer runs at least 7 times
faster for the processor, 2 times (usually 3 or 4 times) faster
for the front side bus to the RAM, and 10 times faster for the
memory latency.  And that doesn't even remotely factor in the
speed boost from having faster and bigger level 2 cache.  Is
that server powered by a water wheel or maybe a steam engine?







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

Date: Sun, 24 Sep 2000 17:21:43 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <slrn8sr7bn.jr6.mgjv@martien.heliotrope.home>

On Sun, 24 Sep 2000 05:05:03 GMT,
	Bart Lateur <bart.lateur@skynet.be> wrote:
> Martien Verbruggen wrote:
> 
> >Starting new processes is almost a trivial cost on modern OS's.
> 
> You'll have a hard time convincing me, since my latest experience.

[snip]

> I have been thinking how such a server with noticable slowdown, even
> with a load of one customer (me), is an ideal platform to experiment
> with alternative forms of CGI-compatible scripting (e.g. fastCGI).

The actual spawning, i.e. the work the OS has to do is trivial in
comparison to the startup costs of perl itself, and the work it has to
do compiling the code and all that sort of stuff. But as I said before,
it's not fair to blame CGI for that. Use compiled C programs, and the
cost of CGI are a lot less. Conversely, it's also not fair to disqualify
Perl because of the startup costs of perl. mod_perl, FastCGI, and other
solutions come to mind that can eliminate startup costs.

In other words, I think what you're seeing is not the cost of forking
and execing a process, but the startup of perl and the compilation of
your programs. 

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Think of the average person. Half of
Commercial Dynamics Pty. Ltd.   | the people out there are dumber.
NSW, Australia                  | 


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

Date: Sun, 24 Sep 2000 04:45:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <sn1rssgg32m30spt38h8thnopviks975s2@4ax.com>

Adrian Pepper [MFCF] wrote:

>My candidate for the top ten perl mistakes list
>
>Using close instead of closedir to close a handle opened using opendir.

 1) Using symbolic references to store user data, instead of in a hash.

-- 
	Bart.


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

Date: Sun, 24 Sep 2000 04:30:06 -0000
From: Joseph Cohen <yosef_hacohen@yahoo.com>
Subject: convert from windows to linux
Message-Id: <ssr0qeg3dfrj52@corp.supernews.com>

ive been working on a lot of perl scripts on windows, and they work fine
when i upload them to perl hosts, i get a 500 error
i think its because of the different newlines
i tried writing a script to do it, but it didnt work
does anyone know of any software that will do it?

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Sun, 24 Sep 2000 07:31:13 +0100
From: David Dorward <ddorward@hotmail.com>
To: Joseph Cohen <yosef_hacohen@yahoo.com>
Subject: Re: convert from windows to linux
Message-Id: <39CD9FB1.E1D297C2@hotmail.com>

Joseph Cohen wrote:
> 
> ive been working on a lot of perl scripts on windows, and they work fine
> when i upload them to perl hosts, i get a 500 error
> i think its because of the different newlines
> i tried writing a script to do it, but it didnt work
> does anyone know of any software that will do it?


http://freshmeat.net/search/?q=dos2unix

-- 
David Dorward
http://www.dorward.co.uk/


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

Date: Sat, 23 Sep 2000 17:58:50 -0700
From: "Andrew V. Romero" <Rom22ero@pharmacy.arizona.edu>
Subject: Re: Displaying form Data
Message-Id: <39CD51CA.9DC7C70D@pharmacy.arizona.edu>

Hummmmmm, thanks.  Actually here is what i had tried:

#!d:\perl\bin\Perl.exe
 print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
 print "To: $recipient\n";
 print "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
 print "Subject: Form Data\n\n";

but nothing comes up, so I figure I must be missing something.  I am use to php
where you can just say echo "$name", etc.  Would anyone else care to fill in a
few more lines of the code that Abigail thoughtfully gave me??
Thanks lol
To reply personally, remove all numbers from address.


Abigail wrote:

> Andrew V. Romero (Rome22ro@pharmacy.arizona.edu) wrote on MMDLXXX
> September MCMXCIII in <URL:news:39CD42DF.449E315A@pharmacy.arizona.edu>:
> )) I have the following test html form:
> )) <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> )) <html><head>   <meta http-equiv="Content-Type" content="text/html;
> )) charset=iso-8859-1">   <meta name="Author" content="romero">   <meta
> )) name="GENERATOR" content="Mozilla/4.7 [en] (Win95; U) [Netscape]">
> )) <title>Test</title></head><body>
> )) <form action="mailprint.pl" method="POST">Your Name:&nbsp;<input
> )) type="text" name="name">Email
> )) Address:&nbsp;<input type="text" name="email">Age:&nbsp;<input
> )) type="text" name="age">Favorite
> )) Color:&nbsp;<input type="text" name="favorite_color"><input
> )) type="submit" value="Send"><input type="reset" value="Clear
> )) Form"></form></body></html>
> ))
> )) and I was wondering how to make mailprint.pl that simply displays (in
> )) html) what the user entered into the form.  I have tried several things
> )) but nothing seems to work.
>
> I give you the first lines of your program, and you take it from there, ok?
>
>     #!/usr/local/bin/perl -wT
>
>     use strict;
>     use CGI;
>
> And here's the last line, as a bonus:
>
>     __END__
>
> Abigail
> --
> perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
>           for (s;s;s;s;s;s;s;s;s;s;s;s)
>               {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'

--
Andrew V. Romero
Romer1999o@pharmacy.arizona.edu
Remove the #'s from my address to reply.
http://www.u.arizona.edu/~avr/
ICQ #54080914




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

Date: 24 Sep 2000 01:48:43 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Displaying form Data
Message-Id: <slrn8sqn9h.lo9.abigail@alexandra.foad.org>

Andrew V. Romero (Rom22ero@pharmacy.arizona.edu) wrote on MMDLXXXI
September MCMXCIII in <URL:news:39CD51CA.9DC7C70D@pharmacy.arizona.edu>:
^^ Hummmmmm, thanks.  Actually here is what i had tried:
^^ 
^^ #!d:\perl\bin\Perl.exe
^^  print "Content-type:text/html\n\n";
^^ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
^^ @pairs = split(/&/, $buffer);
^^ foreach $pair (@pairs) {
^^ ($name, $value) = split(/=/, $pair);
^^ $value =~ tr/+/ /;
^^ $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
^^ $FORM{$name} = $value;
^^  print "To: $recipient\n";
^^  print "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
^^  print "Subject: Form Data\n\n";
^^ 
^^ but nothing comes up, so I figure I must be missing something.  I am use to p

Well, yes, you're missing "use CGI;" for instance. Where did you get this
cargo cult code from? It's bad. It's really, really bad.

Besides, the code doesn't even compile.

^^ where you can just say echo "$name", etc.  Would anyone else care to fill in 

Then why switch to Perl if you are familiar with PHP?

^^ few more lines of the code that Abigail thoughtfully gave me??

Here's another hint: don't post Jeopardy style, specially not without
trimming. Djees, you even quoted the signature.



Abigail
-- 
print v74.117.115.116.32;
print v97.110.111.116.104.101.114.32;
print v80.101.114.108.32;
print v72.97.99.107.101.114.10;


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

Date: Sat, 23 Sep 2000 22:21:24 -0700
From: "Andrew V. Romero" <Rom22ero@pharmacy.arizona.edu>
Subject: Re: Displaying form Data
Message-Id: <39CD8F54.F30FEFE@pharmacy.arizona.edu>

Well, from searching around on the internet some more I found that it seems like
most people use a library such as cgi-lib to format the data gathered from
information in a html form.  Is that the "best" or should I say easiest way to do
things?

To Answer a few questions:
Why switch from PHP to Perl?
    -Most servers support perl while not all support PHP including the one I am
looking at posting a web site on.  Maybe I can talk the owners of the server into
installing PHP or is that "language" any good?

Why Post without Trimming?
    -I suppose I could trim but most the time I don't for a variety of reasons.  For
one it takes more time to searh other the relevant information from the other
person's post.  Also, I don't think your computer should have a problem downloading
another few kb of data (or at least I hope it doesn't).  Finally and probably most
importantly when people are searching through newsgroup messages thru deja searches
or similiar search engines many times the engine will find only certain post and you
can't find the original question, or answer.  If we are really that concerned about
conserving space, why are we asking and answering silly questions instead of the
answering relevant ones?  Deep thoughts to ponder lol.
--
Andrew V. Romero
Romer1999o@pharmacy.arizona.edu
Remove the #'s from my address to reply.
http://www.u.arizona.edu/~avr/
http://www.mp3.com/romero
ICQ #54080914




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

Date: Sun, 24 Sep 2000 17:30:44 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Displaying form Data
Message-Id: <slrn8sr7sk.jr6.mgjv@martien.heliotrope.home>

On Sat, 23 Sep 2000 22:21:24 -0700,
	Andrew V. Romero <Rom22ero@pharmacy.arizona.edu> wrote:

[reformatted totally miswrapped article]

> Well, from searching around on the internet some more I found that it
> seems like most people use a library such as cgi-lib to format the
> data gathered from information in a html form.  Is that the "best" or
> should I say easiest way to do things?

best, compared to what? I believe most people use the CGI module to do
CGI work, which I personally see as the better way to go, compared to
any other solutions I've seen for Perl with CGI. Combine that with
mod_perl on Apache, and you've got a pretty good solution.

\begin[slightly]{offtopic}

> To Answer a few questions: Why switch from PHP to Perl?  -Most servers
> support perl while not all support PHP including the one I am looking
> at posting a web site on.  Maybe I can talk the owners of the server
> into installing PHP or is that "language" any good?

If you need/want PHP, find a provider that has it. Rewriting programs
because 'most' providers don't support what you have used is
nonsensical, and wasteful.

\end{offtopic}

\begin[very]{offtopic}

> Why Post without Trimming?  -I suppose I could trim but most the time
> I don't for a variety of reasons.  For one it takes more time to searh
> other the relevant information from the other person's post.  Also, I

[snip of infuriating trollage]

You do not understand Usenet. You need to read the articles posted in
news.announce.newusers. And do it _before_ you answer to this.

And where do you feel you get the right to decide whether or not you can
push a few extra kilobytes down someones link? Many people pay for their
connectivity by the kilobyte.

\end{offtopic}

Oh, yeah... *plonk*. And to quote you: "Deep thoughts to ponder lol."

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


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

Date: Sun, 24 Sep 2000 15:37:18 +1000
From: Derek Thomson <derek@ooc.com.au>
Subject: Re: LWP and proxy
Message-Id: <39CD930E.A10E6889@ooc.com.au>

Hi,

tauras6097@my-deja.com wrote:
> 
> I must go through a proxy at my company.
> 
> Prior to the proxy I could get WEB pages like this:
>   use LWP::Simple;
>   $doc = get 'http://www.some_web_page.com/';
> 
> Very simple and it worked great.
> 
> How do I do this with the proxy?
> I read all the UserAgent examples and still can't figure it out.

Take a look at the LWP::UserAgent documentation with the command:

perldoc LWP::UserAgent

It describes how to use the 'proxy' method to set proxies.

Regards,
Derek.


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

Date: Sun, 24 Sep 2000 13:04:35 +1000
From: Derek Thomson <derek@ooc.com.au>
Subject: Re: matching a date
Message-Id: <39CD6F43.87D2B2F6@ooc.com.au>

Hi Pierre,

tuple wrote:
> 
> Hello,
> 
> How can i match a date given in something like this:
>     Exchange   2000-09-23  19:37:25    EST
> 
> /\b20[0-9]{2}-[0-1][0-9]-[0-3][0-9]\b/ would work
> but would match  2000-19-39 too.
> 
> I' ve search comp.lang.perl.* with the pattern "date" in a
> power search but it returns nothing !! Very strange.

That's an interesting question. You don't want things that just look
like a date, but that are actually valid dates.

I don't think you can actually do this with a regex, as you need to
capture the correct behaviour for leap years, not to mention simply
matching up the  months to their correct number of days within said
regex.

It's probably best to split this into two steps. First, find the string
that you suspect is a date. Then, use the timelocal function in the
Time::Local module to check it.

Here's an example that checks to see if anything that looks like a date
is valid in the standard input.

This example extends that given on page 81 of the Perl Cookbook. If you
want more help, look there.

Regards,
Derek

----------

use Time::Local;

while(<>) {
  while (/(\d+)-(\d+)-(\d+)/g) {
    my ($yyyy, $mm, $dd) = ($1, $2, $3);

    eval { timelocal(0, 0, 0, $dd, $mm, $yyyy); };

    if (!$@) {
        print "$yyyy-$mm-$dd is okay\n";
    } else {
        print "$yyyy-$mm-$dd is not a valid date: $@";
    }
  }
}


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

Date: Sun, 24 Sep 2000 07:58:53 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: multiple ties to a single DB_file
Message-Id: <1ehgdlm.5nj2m920elogN%tony@svanstrom.com>

Bob Walton <bwalton@rochester.rr.com> wrote:

> I'm having a hard time envisioning why one would want to tie two hashes to
> the same dbm-type file, anyway.

Just me playing around with "%$name" and "%new_name = %$name"-like
things.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Sun, 24 Sep 2000 01:47:47 GMT
From: "Neil Watson" <neilw@SPAMidirect.com>
Subject: Newbie needs help with search and replace
Message-Id: <73dz5.32639$M%3.229081@quark.idirect.com>

 I'm trying to write a script that will search and html file and replace
 numbers like -250, 250, 500, 750 with -1, 1, 2, 3.  Here is my script:

 #!/usr/bin/perl -w
 
$new=-5;
$old=-1500;
 
 while ($new<5) {
 	s/$old/$new/g ;
 
 	$new=$new+1
 	 $old=$old+250
 }
 
When I run the script I"m getting the error:

"Use of uninitialized value at ./points line 7."

Can anyone tell me what is wrong with line 7?

Thanks,


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

Date: 24 Sep 2000 02:27:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Newbie needs help with search and replace
Message-Id: <slrn8sqphk.lo9.abigail@alexandra.foad.org>

Neil Watson (neilw@SPAMidirect.com) wrote on MMDLXXXI September MCMXCIII
in <URL:news:73dz5.32639$M%3.229081@quark.idirect.com>:
&&  I'm trying to write a script that will search and html file and replace
&&  numbers like -250, 250, 500, 750 with -1, 1, 2, 3.  Here is my script:
&& 
&&  #!/usr/bin/perl -w
&&  
&& $new=-5;
&& $old=-1500;
&&  
&&  while ($new<5) {
&&  	s/$old/$new/g ;
&&  
&&  	$new=$new+1
&&  	 $old=$old+250
&&  }
&&  
&& When I run the script I"m getting the error:
&& 
&& "Use of uninitialized value at ./points line 7."
&& 
&& Can anyone tell me what is wrong with line 7?


Well, what are you actually trying to modify? You haven't read anything,
and you're not producing any output. So, on what is the substitution
acting?

Also note that -5 * 250 == -1250 and that '-150000' becomes '-1'.

Perhaps you want:

    perl -i -lwpe 's.(\d+).int ($1 / 250) == $1 / 250 ? $1 / 250 : $1.eg' file



Abigail
-- 
print v74.117.115.116.32, v97.110.111.116.104.101.114.32,
      v80.101.114.108.32, v72.97.99.107.101.114.10;


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

Date: Sun, 24 Sep 2000 02:01:05 GMT
From: Alex Hart <news@althepal.com>
Subject: perl 5.6, Net::POP3, database files, and more
Message-Id: <39CD63E8.8D98925F@althepal.com>

1. In perl 5.6, I've had problems with the Net::POP3 module. Has anyone
else noticed this? The perl code that worked in 5.004 does not work in
5.6.

2. Are the database files (hashes opened with dbmopen) done differently
in perl5.6? I couldn't seem to read my old files with 5.6.  Also, it
didn't seem to put the ".db" extensions on the files.  Have others
noticed this?

3. One more thing.  If I'm using some configuration variables in a
program that is run quite often, am I better off using a database or a
flat file.  There are only about 10 variable that I need to set.  Does
it make a difference? Will there be any performance difference either
way?  I don't know if it matters or not, but it is a cgi program.

Any help is appreciated.

Alex Hart

no sig




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

Date: 24 Sep 2000 03:54:41 GMT
From: Justin McNutt <mcnuttj@nin.iats.missouri.edu>
Subject: Perl IPC - Looking for a suggestion
Message-Id: <8qjtu1$7ks$1@dipsy.missouri.edu>

Okay, I've got a script that *works*, but it doesn't do what I want.

<grin>

Here's the relevant code:

====Code Snippet====
for ( $x=1 ; $x<255 ; $x++ ) {
  $kidpid = open(README, "-|");
  if ( $kidpid ) {  # Parent
    while ( <README> ) {
      # Store output in array @var
      # Indexed by $x.
    }
    close(README) || warn "child exited $?";
  } else {	# Child
    die "Couldn't fork." unless defined $kidpid;
    # Get data via SNMP function call.
    print $var;
    exit;
  }
}

foreach $this ( @var ) {
  # Print the array.
}
====End Code Snippet====

I left some of that as pseudo-code comments for brevity.  Besides,
that part works.

Technically, this does what I want.  It forks a process, which
makes an SNMP call to some device and prints tha results to STDOUT.
STDOUT is redirected back to the parent via the filehandle README.

The child then exits, and README is closed by the parent.  All nice
and clean.  The program does this 254 times, and then prints out
its results.

Well, that's all well and good that it seems like I can do IPC, but
the original idea was to fork ~250 processes, all of which are making
SNMP calls in parallel.  The parent should be able to get their
output, preferably not by using a file or a named pipe as the IPC
method.

It seemed for a moment that I could use socketpair(), but I ran into
the problem that I can't make the name of the filehandle itself a
variable (or I don't know how).  Can I do that?  Make the filehandle
itself vary with $x (the index in the for loop)?

If that were possible, couldn't I then have two loops - one that forks
a zillion processes (yes, I have the resources, although I'll probably
step it back to 10 or 20 in the final version), and one that goes back
and collects all the answers (and reaps the children)?

Ideas welcome, e-mail appreciated but not required (I'll be back), and,
of course, many thanks in advance.

--J


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

Date: Sun, 24 Sep 2000 04:14:27 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl IPC - Looking for a suggestion
Message-Id: <39CD7FB3.21569877@rochester.rr.com>

Justin McNutt wrote:
 ...
> It seemed for a moment that I could use socketpair(), but I ran into
> the problem that I can't make the name of the filehandle itself a
> variable (or I don't know how).  Can I do that?  Make the filehandle
> itself vary with $x (the index in the for loop)?
 ...
> --J
There are at least three ways:

     $fh=*FILEHANDLE;

     use FileHandle;
     $fh=FileHandle->new(); #anonymous filehandle

     use IO::File; #5.004 or higher
     $fh=IO::File->new();

You can then use $fh anywhere where you would otherwise use a bareword
filehandle.  You can store it arrays or hashes, too, but then you have
to be careful about how you use it.  If it is in $array[0], for example,
you would have to do:

     print {$array[0]} $whatever;

for example.  See recipe 7.16 in Perl Cookbook.
-- 
Bob Walton


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

Date: Sun, 24 Sep 2000 04:04:34 GMT
From: Randy <randy_734@my-deja.com>
Subject: Perl2EXE worthwhile?
Message-Id: <39cd7cbe.139635578@207.126.101.100>

Anyone have experience with a product called Perl2EXE?  They claim it
will compile Perl scripts into stand alone executable files which
require no .dlls.  This appeals to me, I need to send the programs to
clients who may or may not have Perl installed.  Your comments are
appreciated.

Randy Harris


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

Date: 24 Sep 2000 06:23:56 GMT
From: abigail@foad.org (Abigail)
Subject: References and local
Message-Id: <slrn8sr7dg.lo9.abigail@alexandra.foad.org>



The perlsub manpage says:

    A `local' just gives temporary values to global (meaning package)
    variables. It does not create a _local_ variable.

The perlref manpage says:

    By using the backslash operator on a variable, subroutine, or
    value.  (This works much like the & (addressof) operator in C.)
    This typically creates another reference to a variable, because
    there's already a reference to the variable in the symbol table.


So, I would think that the following program:

    $var = "foo";
    $ref = \$var;
    local $var = "baz";
    print $$ref;

would print 'baz'. After all, $ref is a reference to $var, and the local
makes $var get a local _value_. Without the local, the program prints
'baz', but with the local, the program prints 'foo', as if local produces
the new variable, instead of a new value.


I asked about this on IRC, and uri gave me an explaination from the
implementation side; how it works with SVs and such. But I don't
find that acceptable, as SVs don't exist on the language level; they
are implementation details, and a next version of Perl might do it
differently.

I think that one of the following is true:

    1)  This behaviour is explained in the manual, and I just don't
        understand the manual.
    2)  The documentation is incomplete.
    2a) The documentation is wrong.
    3)  It's a bug.
    3a) It's a bug and will be fixed in the next release.
    4)  Yeah, it's a case of the implementation surfacing on the
        language level, but we don't really care.
    5)  We are Larry. Resistance is futile. You will be assimilated.


I really hope for 3a), as that will make my 'deferred_interpolation'
module much more useful. ;-)



Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: Sun, 24 Sep 2000 03:15:40 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Testing file for directory: doesn't work
Message-Id: <39CD71EC.A06510DF@rochester.rr.com>

hiroshiishii@my-deja.com wrote:
> 
> Hi all:
> 
> I am programming to process certain files from the entire directory.
> I came up with the following recursive subroutine.
> 
> When I test a file for directory in the line 18 below, test failes.
> Because $file doesn't have a complete PATH.  (I started perl from my
> local subdirectory.)
> 
> QUESTION: How can I make this test work and call this sub recursively?
> 
> T.I.A.
> 
> -Hiroshi
> 
> #!/usr/local/bin/perl5 -w
> #use strict;
> # This lists all files including subdirectories.
> 
> print "Which directory? \n";
> $start_dir = <STDIN>;
> chomp $start_dir;
> search($start_dir);
> 
> #***********
>  sub search
> #***********
> {
>         my $dir = shift;
>         opendir(DIR, $dir) or die "Cannot opendir $dir:$!";
>         while (my $file = readdir DIR)
>         {
>                 next if ($file eq "." || $file eq "..");
>                 if (-d $file) {
>                 ############# (Line 18:)
>                         search($file);
>                         next;
>                 }
>                 print "$file\n";
>         }
>         closedir(DIR);
> }
 ...
You should consider what happens to your global filehandle variable DIR
when you call your routine recursively (hint: it gets clobbered).  Then
you should consider the File::Find module, which should take care of all
that for you.
-- 
Bob Walton


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

Date: Sun, 24 Sep 2000 03:27:31 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: The best tutorial?
Message-Id: <39CD74B3.36E5D2B2@rochester.rr.com>

Giulio Agostini wrote:
> 
> Hi, I'd like to teach myself Perl.
> What's the best place to start? Maybe a free online tutorial?
> 
> Thanks a lot.
> Ciao, Giulio
 ...

The best place to start is with the book "Learning Perl" by Randall
Schwartz, Tom Christiansen, and Larry Wall.

    http://www.oreilly.com

If you would like to try on-line tutorials, see:

    http://www.perl.com/reference/query.cgi?tutorials

And, of course, don't forget the wealth of info that's already on your
hard drive if you have installed Perl.  At your command prompt, type:

    perldoc perldoc
-- 
Bob Walton


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

Date: Sat, 23 Sep 2000 22:12:19 -0600
From: "Michael Love" <noone@nospam.com>
Subject: Re: Time Zone conversion
Message-Id: <39cd7fd0.0@oracle.zianet.com>

I might have solved this one. I found a collection of files at
ftp://elsie.nci.nih.gov/pub/ that have a database of all of this
information. All I have to do is to write a module to parse through it. I'll
let you know how it turns out.




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

Date: Sun, 24 Sep 2000 13:47:07 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: variable -> constant?
Message-Id: <slrn8sqqpb.jr6.mgjv@martien.heliotrope.home>

On 24 Sep 2000 00:33:15 GMT,
	Abigail <abigail@foad.org> wrote:
> Neil Conway (nconway@klamath.dyndns.org) wrote on MMDLXXX September
> MCMXCIII in <URL:news:39CD3F48.9070106@klamath.dyndns.org>:
> () 
> () I'd like this code to print 'helloworld'. How do you do this?
> 
> 
> Trivial.
> 
>     sub test {shift -> ()}

To the OP:

This works, because the constant pragma currently implements constants
as subroutines. This is documented, but with the proviso 'In the current
implementation'. I doubt that it will ever change considerably, unless
it becomes part of the Perl core language (which I doubt).

What I'm trying to say is: Thi swill work, and is correct as documented,
but there are no guarantees that it will keep working. But then,
Abigail will tell you that there are no guarantees that anything in perl
will work in the future :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's not a lie, it's a
Commercial Dynamics Pty. Ltd.   | terminological inexactitude.
NSW, Australia                  | 


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

Date: Sun, 24 Sep 2000 03:50:13 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: vertical text renderer
Message-Id: <39CD7A04.44262765@rochester.rr.com>

Richard Ireland wrote:
> 
> Does anyone know of a perl script that can accept a query string with a
> text field and retrun a content-type: image/gif with the text rendered
> vertically.
> 
> It might also accept other paramaters like bgcolor, font-color,
> font-face, alignment, orientation, transparent etc (these would be
> useful, but not essential).
> 
> I expect it will need some libaries like cgi-lib and gm etc.
> 
> I could write it myself, but there's no point re-inventing the wheel !!!
> (unless someone wants to pay me to do it !!!!!!)
> 
> Richard Ireland
 ...
Check out the GD module.  It has a stringUp method that renders text
vertically.  You may have a problem finding a version that supports GIF
files -- the version that came with the first edition of the Perl
Resource Kit for Win32 did, but it seems that GIF support has been
removed from later versions.
-- 
Bob Walton


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

Date: Sat, 23 Sep 2000 22:50:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: vertical text renderer
Message-Id: <39CD9610.CCF04118@stomp.stomp.tokyo>

Richard Ireland wrote:
 
> Does anyone know of a perl script that can accept a query string with a
> text field and retrun a content-type: image/gif with the text rendered
> vertically.
 
> It might also accept other paramaters like bgcolor, font-color,
> font-face, alignment, orientation, transparent etc (these would be
> useful, but not essential).
 
> I expect it will need some libaries like cgi-lib and gm etc.
 
> I could write it myself, but there's no point re-inventing the wheel !!!


Oh? Why would you use a module for this? Writing your
own script is easy and more imaginative. You can do 
'things' with your own script, modules cannot even 
begin to do.

Modules are for Obessive Techno-Geekster Perl 5 
Cargo Cultists Copy & Paste Specialists who don't 
have a clue how to write a program.

Look over my five minute test script and you will note
a high potential to do whatever you wish, not what some
Cargo Cult module forces you to do.

Toss in some html tags, like center, division, font
size and color, perhaps even sup & sub, and you have
a killer look to your page. Easy to do without any
need to print a graphic content type. Use a standard
img src tag in conjunction with <br clear="left"> or
right, whatever. Just a matter of using something like
my test script but for html rather than plain text.

Reinventing the wheel you say? Well I say why strap
module training wheels on your script when you can
give your script wings of an eagle to soar to new
heights unimaginable by Perl 5 Cargo Cultists.


Godzilla!
-- 
Androids And More
  http://la.znet.com/~callgirl/android.html



TEST SCRIPT:
____________


#!/usr/local/bin/perl

print "Content-type: text/plain\n\n";

$string = "VERTICAL TEXT";

@Array = split (//, $string);

foreach $letter (@Array)
 { print "     $letter\n"; }

print "\n\n";

$counter = 1;

foreach $letter (@Array)
 {
  print " " x $counter;
  print "$letter\n";
  $counter++;
 }

print "\n\n";

$counter = 13;

foreach $letter (@Array)
 {
  print " " x $counter;
  print "$letter\n";
  $counter--;
 }


print "\n\n";

$counter = 1;

foreach $letter (@Array)
 {
  if ($counter < 9)
   {
    if ($letter eq "T")
     { print "    TEXT\n"; }
    else
     { print "    $letter\n"; }
   }
  else
   { last; }
  $counter++;
 }

exit;



PRINTED RESULTS:
________________


     V
     E
     R
     T
     I
     C
     A
     L
      
     T
     E
     X
     T


 V
  E
   R
    T
     I
      C
       A
        L
          
          T
           E
            X
             T


             V
            E
           R
          T
         I
        C
       A
      L
      
    T
   E
  X
 T


    V
    E
    R
    TEXT
    I
    C
    A
    L


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

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


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