[19032] in Perl-Users-Digest
Perl-Users Digest, Issue: 1227 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 1 18:05:42 2001
Date: Sun, 1 Jul 2001 15:05:07 -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: <994025107-v10-i1227@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 1 Jul 2001 Volume: 10 Number: 1227
Today's topics:
Abigail's japh (Was: Re: Faster yet way to count lines (Tony L. Svanstrom)
Re: Abigail's japh (Was: Re: Faster yet way to count li (Tad McClellan)
Re: Basic Questions about Locking a DBM (Garry Williams)
Re: Code Review Needed! <redsquirreldesign@yahoo.com>
Re: Code Review Needed! <krahnj@acm.org>
Re: FAQ 9.15: How do I tell lies about decoding a CGI f (David H. Adler)
Re: FAQ 9.15: How do I tell lies about decoding a CGI f <godzilla@stomp.stomp.tokyo>
Re: FAQ 9.15: How do I tell lies about decoding a CGI f (Tony L. Svanstrom)
Re: FAQ 9.15: How do I tell lies about decoding a CGI f (Steven Smolinski)
Re: FAQ 9.15: How do I tell lies about decoding a CGI f (Tony L. Svanstrom)
Re: Faster yet way to count lines in a file (or at leas <joe+usenet@sunstarsys.com>
How inefficient is it to use name_lc ? <foojh@hotmail.com>
Re: inline average <nogard@gnosrehtaew.ten>
Re: Newbie - Unix Commands in Perl (Tad McClellan)
Re: Newbie - Unix Commands in Perl <krahnj@acm.org>
Re: Perl 6: -> vs . <laszlo.gerencser@portologic.com>
Re: Perl 6: -> vs . (Tad McClellan)
Re:FAQ 9.15: How do I tell lies about decoding a CGI fo <godzilla@stomp.stomp.tokyo>
Re: read/write ksh env array in Perl? (Sergio Vidales)
Re: read/write ksh env array in Perl? (Steven Smolinski)
Re: read/write ksh env array in Perl? (Sergio Vidales)
Re: Regexp problem <jan@klaverstijn.nl>
Re: Selling Scripts (isterin)
Re: String question <uri@sysarch.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 01 Jul 2001 18:00:51 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Abigail's japh (Was: Re: Faster yet way to count lines in a file (or at least cooler))
Message-Id: <1evvu7o.wxe55ewzedj4N%tony@svanstrom.com>
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> Benjamin Goldberg <goldbb2@earthlink.net> writes:
>
> > Cute script, but it forces perl to search for newlines, split on them,
> > and increment $. for each one. Counting newlines can be done faster
> > with:
> > #!/usr/local/bin/perl
> > $/ = \( 1<<10 );
> > $. += tr/\n// while <>;
> ^^^^^^^^^^^^^^^^^^^^^^
>
> According you your above reasoning, this will overcount them.
> I still think Abigail's japh is the coolest way- in script form:
>
> #!/usr/bin/perl -wlp
>
> } $_ = $.; {
>
> __END__
Hmmmm... could anyone explain that one step-by-step?
/Tony
--
the truth is dead, faith is gone, reality killed... ruled by the plastic
laws of modern life we're pushed towards the hell of personal doubt,
betrayal, hate, lust and murder... the now has become an illusion, a
paradise of a dead tomorrow... (c)2000-2001 tony@svanstrom.com
------------------------------
Date: Sun, 1 Jul 2001 13:27:11 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Abigail's japh (Was: Re: Faster yet way to count lines in a file (or at least cooler))
Message-Id: <slrn9junbf.2ur.tadmc@tadmc26.august.net>
Tony L. Svanstrom <tony@svanstrom.com> wrote:
>Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>> Benjamin Goldberg <goldbb2@earthlink.net> writes:
>>
>> > Counting newlines can be done faster
>> I still think Abigail's japh is the coolest way- in script form:
>>
>> #!/usr/bin/perl -wlp
>>
>> } $_ = $.; {
>>
>> __END__
>
>Hmmmm... could anyone explain that one step-by-step?
1) read up on the -p switch in perlrun.var
2) insert the code above where is says "... # your program goes here"
3) realize that you can have a continue block associated with
a naked block (even a naked block that has no statements in it).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 01 Jul 2001 19:38:31 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Basic Questions about Locking a DBM
Message-Id: <slrn9juv1o.pcq.garry@zfw.zvolve.net>
On 28 Jun 2001 13:12:17 -0700, dave <usted@cyberspace.org> wrote:
> open (DBLOCK, "$db_lock") or bail("Cannot open lock file $db_lock
> $!");
> flock(DBLOCK, LOCK_EX);
That won't succeed on most platforms because the file was not opened
for output.
open (DBLOCK, ">> $db_lock") or ...
>
> #dbmopen, tie, save the world here, but most likely:
> #open something
> #write to it
> #close it
>
> close (DBLOCK) or bail("Can't close size file $db_lock $!");
> flock(DBLOCK, LOCK_UN);
>
> So the basic idea is that you have a blank file that everybody locks
> on to take turns writing to the 'real' file that you are trying to
> protecto from concurrent access.
>
> dbmopen calls tie() now anyway so don't worry about it being
> deprecated
But it's trivial to convert dbmopen() to tie(), so why leave it
subject to a future failure?
--
Garry Williams
------------------------------
Date: Sun, 01 Jul 2001 19:59:06 GMT
From: "Dave Hoover" <redsquirreldesign@yahoo.com>
Subject: Re: Code Review Needed!
Message-Id: <eiL%6.101915$mG4.48474537@news1.mntp1.il.home.com>
John W. Krahn wrote ...
> From Soapbox.pm
>
> ###############################################
> # Cleaining and preparing terms for searching #
> # action: assigning to $s->{terms} #
> ###############################################
> sub formatTerms {
> my $s = shift;
> my @search = split(/[^\w']+/, $s->{param}{search});
> # ^^^
> # @search contains only \w and ' characters.
>
> for (@search) {
> unless (/^\W+$/) {
>
> # This only lets \w characters through, strings with an ' in them don't
> get this far.
>
> s/\Q'/'\E/g; # Converting apostrophe
>
> # The substitution does nothing, no apostrophes.
>
> push(@{$s->{terms}}, $_)
> }
> }
> }
>
>
> sub formatTerms {
> my $s = shift;
> my @search = $s->{param}{search} =~ /([\w']+)/g;
This is very cool. I tested it and it obviously does what it needs to do,
but I'm not sure how. Why did you use this rather than the split, is it
faster?
> for (@search) {
> s/'/'/g; # Converting apostrophe
> push @{$s->{terms}}, $_;
> }
> }
Once again John, thank you.
=====
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave
------------------------------
Date: Sun, 01 Jul 2001 21:24:35 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Code Review Needed!
Message-Id: <3B3F9560.33CE0C05@acm.org>
Dave Hoover wrote:
>
> John W. Krahn wrote ...
> > From Soapbox.pm
> >
> > ###############################################
> > # Cleaining and preparing terms for searching #
> > # action: assigning to $s->{terms} #
> > ###############################################
> > sub formatTerms {
> > my $s = shift;
> > my @search = split(/[^\w']+/, $s->{param}{search});
> > # ^^^
> > # @search contains only \w and ' characters.
> >
> > for (@search) {
> > unless (/^\W+$/) {
> >
> > # This only lets \w characters through, strings with an ' in them don't
> > get this far.
> >
> > s/\Q'/'\E/g; # Converting apostrophe
> >
> > # The substitution does nothing, no apostrophes.
> >
> > push(@{$s->{terms}}, $_)
> > }
> > }
> > }
> >
> >
> > sub formatTerms {
> > my $s = shift;
> > my @search = $s->{param}{search} =~ /([\w']+)/g;
>
> This is very cool. I tested it and it obviously does what it needs to do,
> but I'm not sure how. Why did you use this rather than the split, is it
> faster?
Because Randal says so! :-)
This only extracts the strings you want while split can put a null
string in the first element.
$ perl -e'$x = "#!test[]{}one()^%two\/?"; @x = split /[^\w]+/, $x; print
">$_<\n" for @x'
><
>test<
>one<
>two<
$ perl -e'$x = "#!test[]{}one()^%two\/?"; @x = $x =~ /(\w+)/g; print
">$_<\n" for @x'
>test<
>one<
>two<
John
--
use Perl;
program
fulfillment
------------------------------
Date: 1 Jul 2001 16:31:28 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: FAQ 9.15: How do I tell lies about decoding a CGI form?
Message-Id: <slrn9juk30.fli.dha@panix2.panix.com>
In article <3B3F3FEB.133FD97C@stomp.stomp.tokyo>, Godzilla! wrote:
> PerlFAQ Server wrote:
>
>> How do I decode a CGI form?
>
>> You use a standard module, probably CGI.pm. Under no circumstances
>> should you attempt to do so by hand!
>
>
> (snipped blatant idiocy)
>
>
> This specific FAQ ranges from mule manure to idiocy to outright lies.
>
> Posting this type of mule manure, posting this type of deceit, is
> not only a display of a lack of professionalism, it is also a display
> of highly unethical behavior.
>
> This is a document clearly written by a deceitful blithering idiot
> and appears to me to be a deliberate troll article.
>
> Interesting to note this name, PerlFAQ Server, is being used to
> impotently legitimize troll articles, much in the same manner
> Tad McClellan attempts to legitimize his fake newsgroup FAQ.
I'd find it more "interesting" if you would indicate what you think is
wrong with it, rather than just saying that it is "a deliberate
troll article".
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
_Day of Wrath_ is probably Dreyer's most popular film, which already
indicates something of the problems it poses.
- David Bordwell, The Films of Carl-Theodor Dreyer
------------------------------
Date: Sun, 01 Jul 2001 10:44:41 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 9.15: How do I tell lies about decoding a CGI form?
Message-Id: <3B3F6188.A4FE1FBB@stomp.stomp.tokyo>
"David H. Adler" wrote:
> In article <3B3F3FEB.133FD97C@stomp.stomp.tokyo>, Godzilla! wrote:
> > PerlFAQ Server wrote:
> >> How do I decode a CGI form?
> >> You use a standard module, probably CGI.pm. Under no circumstances
> >> should you attempt to do so by hand!
> > (snipped blatant idiocy)
> > This specific FAQ ranges from mule manure to idiocy to outright lies.
> > Posting this type of mule manure, posting this type of deceit, is
> > not only a display of a lack of professionalism, it is also a display
> > of highly unethical behavior.
> > This is a document clearly written by a deceitful blithering idiot
> > and appears to me to be a deliberate troll article.
> > Interesting to note this name, PerlFAQ Server, is being used to
> > impotently legitimize troll articles, much in the same manner
> > Tad McClellan attempts to legitimize his fake newsgroup FAQ.
> I'd find it more "interesting" if you would indicate what you think is
> wrong with it, rather than just saying that it is "a deliberate
> troll article".
It is of no surprise both your reading comprehension skills and
your Perl skills are such you cannot surmise truth for yourself.
Godzilla!
------------------------------
Date: Sun, 01 Jul 2001 17:56:37 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: FAQ 9.15: How do I tell lies about decoding a CGI form?
Message-Id: <1evvts5.17v4blwgysav4N%tony@svanstrom.com>
David H. Adler <dha@panix.com> wrote:
> In article <3B3F3FEB.133FD97C@stomp.stomp.tokyo>, Godzilla! wrote:
> > PerlFAQ Server wrote:
> >
> >> How do I decode a CGI form?
> >
> >> You use a standard module, probably CGI.pm. Under no circumstances
> >> should you attempt to do so by hand!
> >
> >
> > (snipped blatant idiocy)
> I'd find it more "interesting" if you would indicate what you think is
> wrong with it, rather than just saying that it is "a deliberate
> troll article".
"Godzilla" is the troll, but besides that... "Under no circumstances
should you attempt to do so by hand!" is just bs; unless you don't know
what you're doing it's very easy to do it without CGI.pm.
/Tony
--
the truth is dead, faith is gone, reality killed... ruled by the plastic
laws of modern life we're pushed towards the hell of personal doubt,
betrayal, hate, lust and murder... the now has become an illusion, a
paradise of a dead tomorrow... (c)2000-2001 tony@svanstrom.com
------------------------------
Date: Sun, 1 Jul 2001 19:25:24 +0000 (UTC)
From: steven.smolinski@sympatico.ca (Steven Smolinski)
Subject: Re: FAQ 9.15: How do I tell lies about decoding a CGI form?
Message-Id: <9hntf4$d20$1@taliesin.netcom.net.uk>
Tony L. Svanstrom <tony@svanstrom.com> wrote:
>
> "Godzilla" is the troll, but besides that... "Under no circumstances
> should you attempt to do so by hand!" is just bs; unless you don't
> know what you're doing it's very easy to do it without CGI.pm.
Yeah, it is bs, but you have to remember the audience. Someone who
doesn't need CGI.pm probably would know to consult the RFCs and build
his own.
Besides, most people, upon asking this question, want a pre-rolled
solution that handles the difficult aspects, which CGI.pm provides.
That is the point of code re-use.
Steve
--
Steven Smolinski => http://arbiter.ca/
------------------------------
Date: Sun, 01 Jul 2001 21:25:49 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: FAQ 9.15: How do I tell lies about decoding a CGI form?
Message-Id: <1evw3pe.a3gmsk12pqbbwN%tony@svanstrom.com>
Steven Smolinski <steven.smolinski@sympatico.ca> wrote:
> Tony L. Svanstrom <tony@svanstrom.com> wrote:
> >
> > "Godzilla" is the troll, but besides that... "Under no circumstances
> > should you attempt to do so by hand!" is just bs; unless you don't
> > know what you're doing it's very easy to do it without CGI.pm.
>
> Yeah, it is bs, but you have to remember the audience. Someone who
> doesn't need CGI.pm probably would know to consult the RFCs and build
> his own.
>
> Besides, most people, upon asking this question, want a pre-rolled
> solution that handles the difficult aspects, which CGI.pm provides.
>
> That is the point of code re-use.
The point of a FAQ isn't lying to the ones reading it, and justifying it
by saying that the readers are so stupid that you're just protecting
them.
/Tony
--
the truth is dead, faith is gone, reality killed... ruled by the plastic
laws of modern life we're pushed towards the hell of personal doubt,
betrayal, hate, lust and murder... the now has become an illusion, a
paradise of a dead tomorrow... (c)2000-2001 tony@svanstrom.com
------------------------------
Date: 01 Jul 2001 13:35:15 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Faster yet way to count lines in a file (or at least cooler)
Message-Id: <m37kxsimcs.fsf@mumonkan.sunstarsys.com>
Benjamin Goldberg <goldbb2@earthlink.net> writes:
> Cute script, but it forces perl to search for newlines, split on them,
> and increment $. for each one. Counting newlines can be done faster
> with:
> #!/usr/local/bin/perl
> $/ = \( 1<<10 );
> $. += tr/\n// while <>;
^^^^^^^^^^^^^^^^^^^^^^
According you your above reasoning, this will overcount them.
I still think Abigail's japh is the coolest way- in script form:
#!/usr/bin/perl -wlp
} $_ = $.; {
__END__
The fastest way would probably either involve slurping the whole
file or using the FAQ answer.
--
Joe Schaefer "Technological progress is like an axe in the hands of a
pathological criminal."
--Albert Einstein
------------------------------
Date: Mon, 2 Jul 2001 00:59:39 +0800
From: "JH Foo" <foojh@hotmail.com>
Subject: How inefficient is it to use name_lc ?
Message-Id: <9hnksr$vh3$1@newsie.singa.pore.net>
Hi all,
I currently work on a farm of web servers dishing out web pages using Perl.
Because I work with a group of collegues on the platform, we have different
naming habits when it comes to upper-lower casings.
As a lazy way of making sure we don't create bugs using tables that we
create, I wrote a DBI-based API which we all use for dbase access.
Basically, when we SELECT records, the API will do a fetchrow_hashref
(name_lc), making all the field names to their lowercase equivalents.
I'd like to poll your opinions on whether the name_lc parameter is a good
idea to (always) implement, especially on a production portal service. Some
of my collegues prefer to use fetchrow_array() instead, and remember which
array cell is for which. I thought their method makes their code sensitive
to table and SQL statement changes.
------------------------------
Date: Sun, 1 Jul 2001 14:06:00 -0700
From: "David Frauzel" <nogard@gnosrehtaew.ten>
Subject: Re: inline average
Message-Id: <9ho2ub$rvu$1@news.aros.net>
Thanks everyone.
Looks as though the concensus is there are two ways, more or less, to get it
done. One is to tweak at the mechanics behind hashes themselves (with tie
tricks); but for some reason that makes me queasy. It feels like changing
the Laws of Physics just to get 1 and 1 to equal 3. ;} I know, I know,
picky picky. Beggars choosers. All that. I am grateful for the examples,
it's something I know I'll want to use eventually.
The second method looks more intriguing (maybe I'm just mystical like that),
where the end goal is to be able to write something like:
> print "The average is ".$values{average}->()."\n\n"; #prints 4.83
(Or if I want to future-proof myself for 6, I guess that would be
"$values{average}.()"? That doesn't sound right...)
... and make the value of {average} a sub. Not quite OOP (like in Java), not
quite an inline function (like in C)...?
Again, thanks for all the advice. It was esoteric, I'm not failing any
homework here, and it's fun to "learn something new every day". :)
Vive le TMTOWTDI!
David Frauzel
------------------------------
Date: Sun, 1 Jul 2001 09:52:08 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie - Unix Commands in Perl
Message-Id: <slrn9juao8.2jl.tadmc@tadmc26.august.net>
John W. Krahn <krahnj@acm.org> wrote:
>Peter wrote:
>>
>> I want to execute the CAT command in Perl,
>> I am using Active Perl in Win2000 .
>> This is my scrip ; and I got the error message :
>> " cat is not reconized as internal or external command .."
>> WHAT IS WRONG???
No need to shout at us. You cannot execute the 'cat' program if
you do not _have_ the cat program. Doesn't DOS have a cat
work-alike? "type" or something?...
>> SCIPT :
>> =====
>> use Shell;
>> cat("<c:/temp/file1.txt", "<c:/temp/file2.txt", ">>c:/temp/file3.lst"
>
>You don't really _need_ the cat command
[ snip the _best_ way (do 'cat' in native Perl) ]
or you write cat as a Perl one-liner, and call it with system():
!system "perl -pe1 @ARGV" or die "problem running system command"; # yuck!
or you go get/install cat written in Perl from:
http://language.perl.com/ppt/src/cat/index.html
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 01 Jul 2001 17:47:23 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Newbie - Unix Commands in Perl
Message-Id: <3B3F6278.FA4DCF85@acm.org>
Tad McClellan wrote:
>
> John W. Krahn <krahnj@acm.org> wrote:
> >Peter wrote:
> >>
> >> I want to execute the CAT command in Perl,
> >> I am using Active Perl in Win2000 .
> >> This is my scrip ; and I got the error message :
> >> " cat is not reconized as internal or external command .."
> >> WHAT IS WRONG???
>
> No need to shout at us. You cannot execute the 'cat' program if
> you do not _have_ the cat program. Doesn't DOS have a cat
> work-alike? "type" or something?...
To concatenate files in DOS you have to use COPY, TYPE just displays a
single file :-)
UNIX: cat file1 file2 file3 file4 > newfile
DOS: copy file1+file2+file3+file4 newfile
UNIX: cat file* > newfile
DOS: copy file*.* newfile
:)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 01 Jul 2001 20:52:19 GMT
From: Laszlo Gerencser <laszlo.gerencser@portologic.com>
Subject: Re: Perl 6: -> vs .
Message-Id: <3B3F8DBD.FBB2D877@portologic.com>
It seems, that perl6 will not be backward-compatible with perl5.
We have to rewrite everythig...
--
Laszlo Gerencser
PortoLogic Ltd.
------------------------------
Date: Sun, 1 Jul 2001 17:06:24 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl 6: -> vs .
Message-Id: <slrn9jv46g.3cf.tadmc@tadmc26.august.net>
Laszlo Gerencser <laszlo.gerencser@portologic.com> wrote:
>
>It seems, that perl6 will not be backward-compatible with perl5.
That is right.
>We have to rewrite everythig...
That is wrong.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 01 Jul 2001 08:21:15 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re:FAQ 9.15: How do I tell lies about decoding a CGI form?
Message-Id: <3B3F3FEB.133FD97C@stomp.stomp.tokyo>
PerlFAQ Server wrote:
> How do I decode a CGI form?
> You use a standard module, probably CGI.pm. Under no circumstances
> should you attempt to do so by hand!
(snipped blatant idiocy)
This specific FAQ ranges from mule manure to idiocy to outright lies.
Posting this type of mule manure, posting this type of deceit, is
not only a display of a lack of professionalism, it is also a display
of highly unethical behavior.
This is a document clearly written by a deceitful blithering idiot
and appears to me to be a deliberate troll article.
Interesting to note this name, PerlFAQ Server, is being used to
impotently legitimize troll articles, much in the same manner
Tad McClellan attempts to legitimize his fake newsgroup FAQ.
faq@denver.pm.org ~ troll
Godzilla!
------------------------------
Date: Sun, 01 Jul 2001 19:18:26 GMT
From: svidales@please.no.spam.usa.net (Sergio Vidales)
Subject: Re: read/write ksh env array in Perl?
Message-Id: <3b3f72aa.2773067@news-server.socal.rr.com>
On Sun, 1 Jul 2001 06:41:00 +0000 (UTC), steven.smolinski@sympatico.ca
(Steven Smolinski) wrote:
>[ Posting once is generally enough. ]
>
>Sergio Vidales <svidales@please.no.spam.usa.net> wrote:
>> A ksh script that I need to use is doing something like this:
>>
>> $ MYARRAY[0]=TEST1
>> $ MYARRAY[1]=TEST2
>> $ echo ${MYARRAY[0]}
>> TEST1
>> $ echo ${MYARRAY[1]}
>> TEST2
>>
>> I need to write a Perl script that can read and write to this array.
>> It must be kept as an env variable since other scripts will read it as
>> well. I have tried using $ENV and assigning it to a Perl array with
>> little success.
>
>A child cannot change the environment of its parent.
>
>Look in perlfaq8:
>
> I {changed directory, modified my environment} in a perl
> script. How come the change disappeared when I exited the
> script? How do I get my changes to be visible?
>
>Steve
>--
>Steven Smolinski => http://arbiter.ca/
Maybe I didn't explain this well enough. My mistake. The Perl script
is the parent process. It must be able to set array env variables. It
will fork child processes which will get a copy of the parent env and
are expecting to see these array env variables.
$ cat parent
#!/usr/bin/perl
$ENV{"TEST"}="This is a test";
system ("./child");
$ cat child
#!/usr/bin/ksh
echo $TEST
$ ./parent
This is a test
I would like to know how I can change the parent script so that it
sets TEST[0], TEST[1], etc... (an array env variable)
The child would then look like this:
#!/usr/bin/ksh
echo ${TEST[0]}
echo ${TEST[1]}
etc... etc... etc...
Thanks,
Sergio
------------------------------
Date: Sun, 1 Jul 2001 19:46:53 +0000 (UTC)
From: steven.smolinski@sympatico.ca (Steven Smolinski)
Subject: Re: read/write ksh env array in Perl?
Message-Id: <9hnunc$fvg$1@taliesin.netcom.net.uk>
Sergio Vidales <svidales@please.no.spam.usa.net> wrote:
> On Sun, 1 Jul 2001 06:41:00 +0000 (UTC), steven.smolinski@sympatico.ca
> (Steven Smolinski) wrote:
>>Sergio Vidales <svidales@please.no.spam.usa.net> wrote:
>>> A ksh script that I need to use is doing something like this:
>>>
>>> $ MYARRAY[0]=TEST1
>>> $ MYARRAY[1]=TEST2
>>> $ echo ${MYARRAY[0]}
>>> TEST1
>>> $ echo ${MYARRAY[1]}
>>> TEST2
>>>
>>> I need to write a Perl script that can read and write to this array.
>>
>>[... snip ...]
>
> Maybe I didn't explain this well enough. My mistake. The Perl script
> is the parent process. It must be able to set array env variables. It
> will fork child processes which will get a copy of the parent env and
> are expecting to see these array env variables.
I tried the obvious things (as I'm sure you have already), and couldn't
make it work.
There is a kludge, however: have the Perl program write the array
variables as ksh assignments to a temp file, and pass the temp file name
to the ksh script to source it. It's not pretty, but it works.
Steve
--
Steven Smolinski => http://arbiter.ca/
------------------------------
Date: Sun, 01 Jul 2001 20:45:40 GMT
From: svidales@please.no.spam.usa.net (Sergio Vidales)
Subject: Re: read/write ksh env array in Perl?
Message-Id: <3b3f8ba5.9168074@news-server.socal.rr.com>
On Sun, 1 Jul 2001 19:46:53 +0000 (UTC), steven.smolinski@sympatico.ca
(Steven Smolinski) wrote:
Thanks!
>Sergio Vidales <svidales@please.no.spam.usa.net> wrote:
>> On Sun, 1 Jul 2001 06:41:00 +0000 (UTC), steven.smolinski@sympatico.ca
>> (Steven Smolinski) wrote:
>>>Sergio Vidales <svidales@please.no.spam.usa.net> wrote:
>>>> A ksh script that I need to use is doing something like this:
>>>>
>>>> $ MYARRAY[0]=TEST1
>>>> $ MYARRAY[1]=TEST2
>>>> $ echo ${MYARRAY[0]}
>>>> TEST1
>>>> $ echo ${MYARRAY[1]}
>>>> TEST2
>>>>
>>>> I need to write a Perl script that can read and write to this array.
>>>
>>>[... snip ...]
>>
>> Maybe I didn't explain this well enough. My mistake. The Perl script
>> is the parent process. It must be able to set array env variables. It
>> will fork child processes which will get a copy of the parent env and
>> are expecting to see these array env variables.
>
>I tried the obvious things (as I'm sure you have already), and couldn't
>make it work.
>
>There is a kludge, however: have the Perl program write the array
>variables as ksh assignments to a temp file, and pass the temp file name
>to the ksh script to source it. It's not pretty, but it works.
>
>Steve
>--
>Steven Smolinski => http://arbiter.ca/
------------------------------
Date: Sun, 1 Jul 2001 23:07:47 +0200
From: "Jan Klaverstijn" <jan@klaverstijn.nl>
Subject: Re: Regexp problem
Message-Id: <9ho3p7$10b7$1@scavenger.euro.net>
Thanks all for your input.
Bernard's suggestion worked and is now in my script. Thanks.
The ones from worrked as well Michael and John did not meet all of my
requirements. I do wonder why Benjamin's
$date = $1 if /^Date:\s(.+)(?:\s\(.+\))?/;
doesn't work. It makes perfect sense to me. But the timezone between parens
remains in $1. Could it be my perl installation? perl -V output folows.
Cheers,
Jan Klaverstijn
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
Platform:
osname=linux, osvers=2.2.10, archname=i586-linux
uname='linux pascal 2.2.10 #4 fri jun 11 12:33:54 mest 1999 i686 unknown
'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O2 -pipe', gccversion=egcs-2.91.66 19990314/Linux
(egcs-1.1.2 release)
cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
stdchar='char', d_stdstdio=undef, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under linux
Compiled at Aug 6 1999 19:43:13
@INC:
/usr/lib/perl5/5.00503/i586-linux
/usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i586-linux
/usr/lib/perl5/site_perl/5.005
.
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schreef in bericht
news:slrn9job9u.112.bernard.el-hagin@gdndev25.lido-tech...
> On Fri, 29 Jun 2001 09:00:05 +0200, Jan Klaverstijn <jan@klaverstijn.nl>
wrote:
> >Hi all,
> >
> >This is what looks to me a simple regexp challenge but it drove me crazy.
> >I'm clearly a newbie at Perl regexp's. So now I turn to you.
> >
> >What I want is to extract the date from a mail header line. The "Date:"
line
> >comes can have an optional timezone at the end. That timezone must be
> >stripped, together with the Date: at the beginning.
> >
> >Date: Mon, 25 Jun 2001 17:56:26 +0200 (CEST)
> >
> >If the timezone was always there it would be easy: $date = $1 if
> >/^Date:\s(.+)\s(\(.+\))/;
> >But this fails to match when the timezone is not there.
> >
> >Date: Mon, 25 Jun 2001 17:56:26 +0200
> >
> >I thought making the timezonepart optional: (\(.+\))?. No luck.
> >
> >How should I approach this to make it work with a single regular
expression?
>
> s/^Date:\s(.+?)(?:\([^)]+\))?$/$1/;
>
> Cheers,
> Bernard
> --
> perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y
#a-zA-Z#d-gu-z#
> chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
> ppevalpereeteueje'
------------------------------
Date: 1 Jul 2001 14:24:24 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Selling Scripts
Message-Id: <db67a7f3.0107011324.666b146b@posting.google.com>
"Misanthrope" <no@spam.net> wrote in message news:<Rbv%6.8953$eL5.958301@newsread1.prod.itd.earthlink.net>...
> <tsee@gmx.net> wrote in message news:9hdka5$if2$07$1@news.t-online.com...
> > "ffg" <john@trumpetweb.co.uk> schrieb im Newsbeitrag
> > news:8or_6.4277$4i5.341643@news1.cableinet.net...
> > In order to make it run, you need perms to be 555 or more.
>
>
> Untrue.
What's untrue. Maybe you want to explain why before you flaunt you ignorance.
Ilya
------------------------------
Date: Sun, 01 Jul 2001 16:41:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: String question
Message-Id: <x7lmm87gaa.fsf@home.sysarch.com>
>>>>> "MI" == Marinus Israel <marinus@nwsoft.net> writes:
>> Doesn't @sorted_strings = sort @strings; work?
MI> No, not in the script I'm using.
and what about sort techniques like the ST or GRT?
if you are note aware of substr, you most likely are not aware of better
ways to sort data in perl. if you call substr on each compare or $diety
forbid, you write your own complete sort algorithm code, you are wasting
electrons.
>> I'd be willing to bet that the sorting algorithm you are working on has
>> already been developed.
MI> Thanks for the help, yes, the algorithm I made has probably been
MI> developped by someone else but I made it so that it fits perfectly
MI> into my program!
so what is this special algorithm?
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 1227
***************************************