[22574] in Perl-Users-Digest
Perl-Users Digest, Issue: 4795 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 31 18:06:35 2003
Date: Mon, 31 Mar 2003 15:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 31 Mar 2003 Volume: 10 Number: 4795
Today's topics:
Re: CGI.pm or roll-your-own? <matthew.p.goff@intel.com>
Re: CGI.pm or roll-your-own? <matthew.p.goff@intel.com>
Re: CGI.pm or roll-your-own? <me@privacy.net>
Re: CGI.pm or roll-your-own? <ethan@draupnir.gso.saic.com>
Changing the process title in ps -ef (Scott)
Re: Changing the process title in ps -ef <grazz@nyc.rr.com>
Re: Cookie Question <flavell@mail.cern.ch>
Cookies from hell (Captain Zod)
Re: Cookies from hell (Malcolm Dew-Jones)
Re: Cookies from hell <flavell@mail.cern.ch>
Re: CPAN is now Matt's Script Archive <kkeller-spammmm@wombat.san-francisco.ca.us>
Re: CPAN is now Matt's Script Archive <me@privacy.net>
Re: CPAN is now Matt's Script Archive <ericw@nospam.ku.edu>
Does Perl can do everything you need in unix shell scri (edu@rd c)
Re: Does Perl can do everything you need in unix shell <bcaligari@fubar.fireforged.com>
Re: Does Perl can do everything you need in unix shell <vilain@spamcop.net>
Re: Does Perl can do everything you need in unix shell <usenet@not-real.org>
Re: implicit vs explicit variable usage in loop w/ rang (Malcolm Dew-Jones)
Loading STDOUT into a variable <sbour@niaid.nih.gov>
Re: Loading STDOUT into a variable <grazz@nyc.rr.com>
Re: Loading STDOUT into a variable <kalinabears@hdc.com.au>
Re: match all but this <michael.p.broida@boeing.com>
Re: MSWin32 Active State Perl Question <kalinabears@hdc.com.au>
Re: Multiple POSTS and GETS from one perl script <tore@aursand.no>
Re: Putative bug inheriting private fields in fields/ba <tarik@alkasab.com>
Re: Removing Brackets <perl-dvd@darklaser.com>
Re: Removing Brackets <alex@alexbanks.com>
Re: Replacing a string in a file <glex_nospam@qwest.net>
Re: Replacing a string in a file <sbour@niaid.nih.gov>
Re: Replacing a string in a file <glex_nospam@qwest.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 31 Mar 2003 11:37:45 -0800
From: "Matthew P. Goff" <matthew.p.goff@intel.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b6a5mh$f5l$1@news01.intel.com>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7llywwkwo.fsf@mail.sysarch.com...
> >>>>> "GR" == Greg Raven <raven@corax.org> writes:
>
> GR> In article <509b3630abaf9f679c15b75f1866e1d0@news.teranews.com>,
> GR> merlyn@stonehenge.com (Randal L. Schwartz) wrote:
> >>
> >> use CGI "param";
> >>
> >> my $name = param('name');
> >> my $age = param('age');
> >>
> >> ... rest of program ...
> >>
> >> You don't have to change a single other thing.
>
> GR> I sure wish it was presented this way in the documentation!
>
> it is.
Wouldn't this thread (with Greg Raven) seem to imply that the CGI.pm POD may
be poorly written for the beginner? It is certainly complete, and
experienced idiomatic programmers are used to it (and value it), but it does
not seem to be intuitive to those new to CGI and Perl. Although there are
web tutorials and books that break down the module fairly well, the first
place people (should) go are the PODs. With that in mind, why not have a
CGI tutorial POD (a la the thread or OO tutorials already included)? New
users could be redirected to the tutorial at the start of the regular POD.
BTW, is it just me, or is cpan.org now redirecting to a certain hated script
archive?
--
Matt Goff <matthew.p.goff@intel.com>
Santa Clara, CA, USA
All opinions expressed are mine, not Intel's
------------------------------
Date: Mon, 31 Mar 2003 11:47:45 -0800
From: "Matthew P. Goff" <matthew.p.goff@intel.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b6a698$feb$1@news01.intel.com>
"Matthew P. Goff" <matthew.p.goff@intel.com> wrote in message
news:b6a5mh$f5l$1@news01.intel.com...
> BTW, is it just me, or is cpan.org now redirecting to a certain hated
script
> archive?
At the expense of the self-reply, I presume that it is now 4/1 somewhere in
the world....
--
Matt Goff <matthew.p.goff@intel.com>
Santa Clara, CA, USA
All opinions expressed are mine, not Intel's
------------------------------
Date: Tue, 1 Apr 2003 08:12:25 +1000
From: "Tintin" <me@privacy.net>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b6aegc$3a5g8$1@ID-172104.news.dfncis.de>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:b69is8$31pei$1@ID-184292.news.dfncis.de...
> I know how to read STDIN and parse its contents, but I have never
> learned any of those other things you mention. I believe that that's
> the reason why it is more difficult to convince me (and a lot of other
> people) about the benefits of CGI.pm, than it is to convince us about
> the benefits of "trusting the experts" in all those other fields.
> Starting to use CGI.pm means that you replace code where you are in
> control with a black box.
I can guarantee you that >99% of beginners (or even intermediates) that copy
cargo cult CGI parsing code wouldn't have a clue what it is precisely doing.
In other words, it's a black box piece of code.
------------------------------
Date: 31 Mar 2003 14:25:36 -0800
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <vrel4njhr3.fsf@draupnir.gso.saic.com>
>>>>> "Tintin" == Tintin <me@privacy.net> writes:
Tintin> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
Tintin> news:b69is8$31pei$1@ID-184292.news.dfncis.de...
>> I know how to read STDIN and parse its contents, but I have never
>> learned any of those other things you mention. I believe that that's
>> the reason why it is more difficult to convince me (and a lot of other
>> people) about the benefits of CGI.pm, than it is to convince us about
>> the benefits of "trusting the experts" in all those other fields.
>> Starting to use CGI.pm means that you replace code where you are in
>> control with a black box.
Tintin> I can guarantee you that >99% of beginners (or even intermediates) that copy
Tintin> cargo cult CGI parsing code wouldn't have a clue what it is precisely doing.
Tintin> In other words, it's a black box piece of code.
For those of you wondering what "Carge Cult" refers to, see:
http://www.physics.brocku.ca/etc/cargo_cult_science.html
--Ethan Brown
--Keyboards: "The Fabulous Pelicans" (www.pelicans.com)
--In a band? Use http://www.WheresTheGig.com for free.
------------------------------
Date: 31 Mar 2003 13:32:45 -0800
From: googlegroups@scottsavarese.com (Scott)
Subject: Changing the process title in ps -ef
Message-Id: <677a147d.0303311332.4bdf90a6@posting.google.com>
Sendmail has the ability to alter the name it displays when someone
does a ps -ef. Instead of displaying /usr/local/bin/perl whatever, I
would like the ability to change what it displays.
Is that possible in perl?
Thanks,
Scott
------------------------------
Date: Mon, 31 Mar 2003 21:56:11 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Changing the process title in ps -ef
Message-Id: <%P2ia.103$n95.123159@twister.nyc.rr.com>
Scott <googlegroups@scottsavarese.com> wrote:
> Sendmail has the ability to alter the name it displays when someone
> does a ps -ef. Instead of displaying /usr/local/bin/perl whatever, I
> would like the ability to change what it displays.
FAQ:
$ perldoc -q "hide perl's command line"
Found in /usr/local/lib/perl5/5.8.0/pod/perlfaq8.pod
Is there a way to hide perl's command line from programs
such as "ps"?
--
Steve
------------------------------
Date: Mon, 31 Mar 2003 20:47:26 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Cookie Question
Message-Id: <Pine.LNX.4.53.0303312039030.2896@lxplus005.cern.ch>
On Mon, Mar 31, Captain Zod inscribed on the eternal scroll:
> I am writing a shopping cart program. The way I designed it is that
> there is one central cgi script which gets called all the time and
> depending on the parameter that is passed to this script different
> part of the script gets executed.
Seems to be a perfectly normal way to organise a program in any
programming language: I don't see how this would involve any
specifically Perl-related problem?
> Now here is the problem:
> If I print http header
------------^^^^^^^^^^^
The response from a CGI process is a CGI response. The similarity to
HTTP headers is intentional, but can sometimes be confusing. It's
best to keep them apart IMHO, even if it sometimes seems pedantic.
> and other things, then I can no longer
> manipulate the cookies. So what is one to do?
Blindingly obvious that you don't put out the CGI response header
until you've decided what the CGI response header should be, no?
> Is there a way to close
> out the current http ( session is right word? ) and start out new so
> that I can manipulate the cookies again?
No, there isn't. If there were, it would be in the CGI specification
for all to see. There's no reason that you should need it, if you
organise your program right. And this _still_ has nothing Perl
specific about it, so this is hardly the right place for the
discussion. Even if there's a very selective coverage of CGI topics
in the Perl FAQ part 9 (look for the 5.8.0 version at least) which
might help to put things in perspective.
good luck
------------------------------
Date: 31 Mar 2003 13:23:35 -0800
From: cptnzod@yahoo.com (Captain Zod)
Subject: Cookies from hell
Message-Id: <9433af5b.0303311323.606a4f6f@posting.google.com>
I am having trouble deleting and getting cookies.
1) I know that I have to set the name without any values to delete,
but its not working. What am I doing wrong?
Here is the content of my cookie.txt
.mydomain.com TRUE / FALSE 1049140874 CARTID
587509
.mydomain.com TRUE / FALSE 1049140874
Elegant_Brass_Lamp
Here is what I am doing to delete the bloody cookie:
print "Set-Cookie: CARTID=; expires=Thu, 01-Jan-1970 00:00:00 GMT;
path=/\n";
This is a shopping cart that I am writing with cartid and various
items. I want to delete everything or edit and just remove one item.
2) I am getting my cookies: $cdata = $ENV{'HTTP_COOKIE'};
I see data in there while my cookie file is empty! I do a print
"$cdata" and I see a couple of items in there! Where are these coming
from? I make sure my program does not set them. They even get set on
the entry to my index.html without even clicking on anything! Is this
some sort of persistant cookie? I am using netscape.
thx
------------------------------
Date: 31 Mar 2003 14:07:43 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Cookies from hell
Message-Id: <3e88bc2f@news.victoria.tc.ca>
Captain Zod (cptnzod@yahoo.com) wrote:
: I am having trouble deleting and getting cookies.
: 1) I know that I have to set the name without any values to delete,
: but its not working. What am I doing wrong?
: Here is the content of my cookie.txt
: .mydomain.com TRUE / FALSE 1049140874 CARTID
: 587509
: .mydomain.com TRUE / FALSE 1049140874
: Elegant_Brass_Lamp
: Here is what I am doing to delete the bloody cookie:
: print "Set-Cookie: CARTID=; expires=Thu, 01-Jan-1970 00:00:00 GMT;
: path=/\n";
: This is a shopping cart that I am writing with cartid and various
: items. I want to delete everything or edit and just remove one item.
: 2) I am getting my cookies: $cdata = $ENV{'HTTP_COOKIE'};
: I see data in there while my cookie file is empty! I do a print
: "$cdata" and I see a couple of items in there! Where are these coming
: from? I make sure my program does not set them. They even get set on
: the entry to my index.html without even clicking on anything! Is this
: some sort of persistant cookie? I am using netscape.
From some old memories, some things to look for...
A cookie can be set with different sub-domains and paths. You need to be
sure you are using the correct sub-domain and path for a cookie (correct
being the same sub-domain and path every time the cookie is used). If the
browser gets two cookies, one for the domain and one for a sub-domain or
one for a path and then another for a sub path, then it can become tricky
to know which cookie is being sent back, and when you delete the cookie
then you may not be deleteing the correct one, and the other cookie (the
one for a higher level sub-domain or path) will then be sent back.
I have a suspicion that some browser/version(s) have bugs handling these
multiple cookies - they get confused and then you can never be sure you
are working with the correct version of the cookie. I do not know this is
a bug in any browser, I just found it sensible to avoid the issue in the
first place.
I find it's sensible to add additional information into the cookie name
and to set the cookie at the highest point that makes sense. So instead of
CARTID, I would normally use something like /my-application/CARTID, set as
high as possible. Multiple applications on the server may see the cookie,
but this also ensures that your multiple pages always get the same cookie,
and the name ensures that two applications will not have cookies that
clash. (Within the application the /my-application/ string is stripped so
that the application internally uses just CARTID.
Also, do you use javascript to manipulate cookies? I'm not sure how those
interact with cookies defined by the server, (i.e. who sees what) but I
would want to make sure I understood that if I used both.
------------------------------
Date: Mon, 31 Mar 2003 23:39:57 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Cookies from hell
Message-Id: <Pine.LNX.4.53.0303312338060.2896@lxplus005.cern.ch>
On Mon, Mar 31, Captain Zod inscribed on the eternal scroll:
> I am having trouble deleting and getting cookies.
You already make that clear. Seems to me now that you're having
trouble engaging in a coherent discussion on a topic that's
appropriate to this newsgroup. Bye.
------------------------------
Date: Mon, 31 Mar 2003 11:31:16 -0800
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: CPAN is now Matt's Script Archive
Message-Id: <425a6b.qpp.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In article <slrnb8h3ts.7f5.clay@panix3.panix.com>, Clay Irving wrote:
> What happened? http://www.cpan.org load Matt's Script Archive.
> April Fools Day isn't until tomorrow.
Well, it's currently 1 April in New Zealand, isn't it? :)
- --keith
- --
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
public key: http://wombat.san-francisco.ca.us/kkeller/kkeller.asc
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj6Il4IACgkQhVcNCxZ5ID8eeQCeNgV3PocsQ2sSbqsDR69jLEBY
pFoAn13lfuuJAIL1zKp54wukXuvRDGVi
=f8On
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 1 Apr 2003 08:19:36 +1000
From: "Tintin" <me@privacy.net>
Subject: Re: CPAN is now Matt's Script Archive
Message-Id: <b6aetq$3btf7$1@ID-172104.news.dfncis.de>
"Clay Irving" <clay@panix.com> wrote in message
news:slrnb8h3ts.7f5.clay@panix3.panix.com...
> What happened? http://www.cpan.org load Matt's Script Archive.
> April Fools Day isn't until tomorrow.
Not all of the world is a day behind (or in some cases years behind).
I think the changes should be made permanent.
------------------------------
Date: Mon, 31 Mar 2003 23:25:51 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: CPAN is now Matt's Script Archive
Message-Id: <pan.2003.03.31.16.25.57.867316.1185@nospam.ku.edu>
On Mon, 31 Mar 2003 14:07:35 -0600, Rich wrote:
> Clay Irving wrote:
>
>> What happened? http://www.cpan.org load Matt's Script Archive. April
>> Fools Day isn't until tomorrow.
>
> Oh man - it got me for a second - try clicking on (most) of the links!
most?
$lynx -dump http://www.cpan.org/ |grep http|grep -c http
158
$lynx -dump http://www.cpan.org/ |grep http|grep -c "index2\.html"
158
Looks like all. nice.
------------------------------
Date: 31 Mar 2003 14:30:50 -0800
From: ecleofe7@yahoo.com (edu@rd c)
Subject: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <1e1c9a33.0303311430.2143c5e@posting.google.com>
hi Guys,
Need your advice.This could be helpfull for those newbie.I
want to learn shell scripting.I just want to know that if you master
the Perl you can overcome all the shell scripting needed in unix,on
w/c you dont need to study those csh,bsh,bash and so on.But what about
PHP,since they are just the same function with perl and this is much
easier to learn?
Thanks in advanced.God Bless to all...
------------------------------
Date: Tue, 1 Apr 2003 00:42:23 +0200
From: "Brendon Caligari" <bcaligari@fubar.fireforged.com>
Subject: Re: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <3e88c538$0$66672$bed64819@news.gradwell.net>
"edu@rd c" <ecleofe7@yahoo.com> wrote in message
news:1e1c9a33.0303311430.2143c5e@posting.google.com...
> hi Guys,
> Need your advice.This could be helpfull for those newbie.I
> want to learn shell scripting.I just want to know that if you master
> the Perl you can overcome all the shell scripting needed in unix,on
> w/c you dont need to study those csh,bsh,bash and so on.But what about
> PHP,since they are just the same function with perl and this is much
> easier to learn?
> Thanks in advanced.God Bless to all...
hi Troll
I'd love to see unix init scrips written in php.
B
------------------------------
Date: Mon, 31 Mar 2003 14:55:37 -0800
From: "Michael Vilain <vilain@spamcop.net>"
Subject: Re: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <news-C2549C.14553631032003@news.tdl.com>
In article <3e88c538$0$66672$bed64819@news.gradwell.net>,
"Brendon Caligari" <bcaligari@fubar.fireforged.com> wrote:
> "edu@rd c" <ecleofe7@yahoo.com> wrote in message
> news:1e1c9a33.0303311430.2143c5e@posting.google.com...
> > hi Guys,
> > Need your advice.This could be helpfull for those newbie.I
> > want to learn shell scripting.I just want to know that if you master
> > the Perl you can overcome all the shell scripting needed in unix,on
> > w/c you dont need to study those csh,bsh,bash and so on.But what about
> > PHP,since they are just the same function with perl and this is much
> > easier to learn?
> > Thanks in advanced.God Bless to all...
>
> I'd love to see unix init scrips written in php.
Although the OP's post is "uninformed" more than trollish, I'll respond
to it. Shell scripting is a useful skill. Being able to code in perl
or php is fine, but you can't manage the system's startup and shutdown
environment with them. Nor can you change or setup a global environment
for users as their shell (if they have one) isn't usually perl or php
but one of the usual suspects.
The most common shell to learn is the Borne shell. bash is a super-set
of that but bash isn't the default shell for Solaris' root, which runs
the startup scripts (it's /sbin/sh and should NOT be changed unless you
know what you're doing otherwise subsequent posts about "I can't login
as root" will be met with "I told you so").
--
DeeDee, don't press that button! DeeDee! NO! Dee...
------------------------------
Date: Mon, 31 Mar 2003 22:54:09 GMT
From: Nicholas Bachmann <usenet@not-real.org>
Subject: Re: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <3E88C5CC.4070402@not-real.org>
edu@rd c wrote:
> hi Guys,
> Need your advice.This could be helpfull for those newbie.I
> want to learn shell scripting.I just want to know that if you master
> the Perl you can overcome all the shell scripting needed in unix,on
> w/c you dont need to study those csh,bsh,bash and so on.But what about
> PHP,since they are just the same function with perl and this is much
> easier to learn?
I think I know what you're asking, and the answer is no. Yes, if you
want to learn Unix you need to know Perl, at least the basics. You also
need to know at least two shells: standard Bourne sh and another shell,
prehaps Bash or Korn shells.
Trying to shortcut the prerequisite knowledge for Unix administration is
not wise; Perl and shell programming are different beasts used for
differenet purposes. You really need to know both.
On the other hand, there is no need at all for you to learn PHP for
general Unix SysAdmin work; almost none is done in PHP.
--
+ Regards, +
+ Nick +
+ +
+ My email address is real +
------------------------------
Date: 31 Mar 2003 11:48:19 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: implicit vs explicit variable usage in loop w/ range regexp
Message-Id: <3e889b83@news.victoria.tc.ca>
Upstart (stimonyhall@netscape.net) wrote:
: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in message news:<3e84b6e6@news.victoria.tc.ca>...
: > This line does not do what you think it does. My added brackets show what
: > it is doing.
: >
: > if ( ($line =~ /^BEGIN:/) ... (/^END:/) ) {
: wow. this is not clear to me for the documentation. any manpage i should
: be reading?
That sounds a bit contradictory to my ear, to say the documentation wasn't
clear and then ask what documentation to read.
I suggest
perldoc perlop
it shows the precedence of the operators, and explains each one. In my
opinion the range operater, in this context, is at the harder end of the
scale to learn, but simple and useful once properly understood. The
documentation may look hard or be unclear because it correctly describes
something that is hard and unclear until you understand it. Then you will
realize the documentation is a straight forward and correct description of
the operator.
: >
: > which is of course the same as
: >
: > if ( ($line =~ /^BEGIN:/) ... ( $_ =~ /^END:/) ) {
: >
: > which is not what you want.
: ok - i'll bite. what do i want? :-)
Since you said this didn't work it is a tautalogical truth that it wasn't
what you wanted. I certainly don't know what you want (perhaps because I
I didn't bother to grok your requirements). I just hoped that seeing
exactly what you were doing might help you figure out the alternate thing
that you need to do instead to perform the action that you want to effect.
------------------------------
Date: Mon, 31 Mar 2003 16:25:11 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Loading STDOUT into a variable
Message-Id: <BAAE1C67.6BA4%sbour@niaid.nih.gov>
I need to parse the output of the ifconfig shell command
(system("ifconfig");) for the current IP address. I know I can redirect the
STDOUT to a temp file and work on that to extract the info I need but is
there any way to assign the content of STDOUT to a variable without writing
it to a file? Can I do this: while (<STDOUT>) ...?
Thank you,
Stephan.
------------------------------
Date: Mon, 31 Mar 2003 21:45:33 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Loading STDOUT into a variable
Message-Id: <1G2ia.102$n95.120047@twister.nyc.rr.com>
Stephan Bour <sbour@niaid.nih.gov> wrote:
> I need to parse the output of the ifconfig shell command
> (system("ifconfig");) for the current IP address. I know
> I can redirect the STDOUT to a temp file and work on that
> to extract the info I need but is there any way to assign
> the content of STDOUT to a variable without writing it to
> a file?
FAQ:
$ perldoc -q "with system"
Found in /usr/local/lib/perl5/5.8.0/pod/perlfaq8.pod
Why can't I get the output of a command with system()?
--
Steve
------------------------------
Date: Tue, 1 Apr 2003 07:43:22 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Loading STDOUT into a variable
Message-Id: <3e88b75e$0$16142@echo-01.iinet.net.au>
"Stephan Bour" <sbour@niaid.nih.gov> wrote in message
news:BAAE1C67.6BA4%sbour@niaid.nih.gov...
> I need to parse the output of the ifconfig shell command
> (system("ifconfig");) for the current IP address. I know I can redirect
the
> STDOUT to a temp file and work on that to extract the info I need but is
> there any way to assign the content of STDOUT to a variable without
writing
> it to a file? Can I do this: while (<STDOUT>) ...?
Just do:
my $output = `ifconfig`;
Then parse $output.
Cheers,
Rob
------------------------------
Date: Mon, 31 Mar 2003 20:08:10 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: match all but this
Message-Id: <3E88A02A.A0CC76AF@boeing.com>
istink wrote:
>
> how do I match all occurrences of this word but not when its between
> these symbols?
>
> I have:
> $str="word123 word123 (word123) word123";
>
> with this:
> s/word123/X/g
> I find 4 occurrences
>
> s/[word123]/X/g
> wont work.
>
> I can imagine this sudo code:
> s/word123 _but_not_inside \(.*\)/X/g
>
> great for html code.
> where:
> <font color="red">my red keyboard</font>
> I would want to replace "red" in the text with blue but I don't want
> to replace the "red" in the font tag.
You (as username "stinkbomb") posted essentially the same
question on Friday, March 28. Please read the responses
given in that thread. For instance, I posted a perfectly
good substitution that will do exactly what you want.
Mike
------------------------------
Date: Tue, 1 Apr 2003 07:39:18 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: MSWin32 Active State Perl Question
Message-Id: <3e88b668$0$16135@echo-01.iinet.net.au>
"BSK" <mooncm.lbkejwiAhEgSfSe@dAcEbSaS> wrote in message
news:XIZha.1449$4P1.128377@newsread2.prod.itd.earthlink.net...
> Rob,
>
> Thanks for your help. I'm new to Win32 Perl, so I'm wondering if the
> Term::Readkey you mentioned is just a simple matter of downloading it from
> CPAN-- or do I have to be careful to make sure that it is compatible with
> Win32? I suspect that there is a UNIX and a Win32 version. Forgive me, I
> should have checked out CPAN before writing this email, but is it possible
> to get Win32 Perl stuff from CPAN in the first place?
>
> Thanks.
>
As with all modules, the source code from cpan is the same for *all*
platforms. It does, however, require compilation, and I suspect that you do
not have a compiler.
If you have ActiveState built perl, you can use 'ppm' to install
pre-compiled versions of many modules.
To see what's available re the Term::* modules, enter:
ppm search Term
If Term-Readkey shows up, install it with:
ppm install Term-Readkey
Looks like it might be called 'TermReadkey' in which case you would:
ppm install TermReadkey
Cheers,
Rob
------------------------------
Date: Tue, 01 Apr 2003 00:59:29 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Multiple POSTS and GETS from one perl script
Message-Id: <pan.2003.03.31.13.45.39.231843@aursand.no>
On Mon, 31 Mar 2003 12:31:47 +0100, Meanblue wrote:
> This is no design flaw - merely me looking at different ways of doing
> the same thing. - I am curious :)
You have yet to tell me something useful about your problem, but as far as
I understand from what you've told me, this _is_ a design flaw.
You _don't_ need multiple scripts to solve the task. You _will_ benefit
from keeping everything in one script, while leaving reusable code in
modules.
--
Tore Aursand
------------------------------
Date: Mon, 31 Mar 2003 19:17:55 GMT
From: Tarik Alkasab <tarik@alkasab.com>
Subject: Re: Putative bug inheriting private fields in fields/base pragma in 5.8.0
Message-Id: <Dv0ia.321832$sf5.301882@rwcrnsc52.ops.asp.att.net>
Oops... broken links now fixed. Sorry.
Tarik Alkasab wrote:
> I'm using the fields and base pragmata in 5.8.0 for some OO stuff I'm
> working on. I find the combination pretty elegant, and appreciate them
> very much.
>
> However, I've encountered a small problem (that vexed me quite a bit
> until I figured out where the issue was). Specifically, if *all* of the
> fields in a super-class are private (i.e., their names start with
> underscores), then sub-classes fail to respect them when inheriting. The
> result is that new fields in the sub-class write themselves into the
> same pseudo-hash slots as the fields of the super class. If there is
> even *one* non-private field in the super-class, then the sub-class
> fields make room for *all* of the super-class fields (even the private
> ones).
>
> The problem can be seen in the following two programs (output included
> after __END__):
>
> http://alfred.hsdb.tufts.edu/src/testfields.pl (broken)
> http://alfred.hsdb.tufts.edu/src/testfields2.pl (pseudo-fixed)
>
> You can find my "perl -V" output at
>
> http://alfred.hsdb.tufts.edu/src/perl-V.txt
>
> Is this a known problem? Is there a patch already available? If not, to
> whose attention should I bring it? It's not a big deal to work around
> ("unused" field, anyone?), but it should probably be fixed.
>
> Thanks,
> Terry
>
> --
> Tarik Alkasab <tarik.alkasab@tufts.edu>
> Senior Systems Architect Phone: 617-636-3912
> Health Sciences Database Project Fax: 617-636-3805
> Research Assistant Professor http://alfred.hsdb.tufts.edu
> Dept. of Fam. Med. and Comm. Health
>
------------------------------
Date: Mon, 31 Mar 2003 19:56:16 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: Removing Brackets
Message-Id: <A31ia.10$NY5.4073@news-west.eli.net>
"Alex Banks" <alex@alexbanks.com> wrote in message
news:3e887a8d$0$4846$cc9e4d1f@news.dial.pipex.com...
> I need to remove matching brackets and everything between them from a
> string... For example:
>
> $temp = "select a.alex, concat(b.firstname, ' ', b.lastname) as name,
> concat('(0', substring(c.number from 3 for 5), ') ',
substring(c.number from
> 7)) as number from tba a, tbb b, tbc c";
>
> ...after the processing $temp should be...
>
> "select a.alex, concat as name, concat as number from tba a, tbb b,
tbc c"
>
> Anyone have a good solution for this?
How about something like:
########################################
$temp = cleanit($temp);
sub cleanit {
my $str = shift;
$str =~ s/\([^\(\)]*?\)//g;
$str = cleanit($str) if ($str =~ /\(.*\)/);
return $str;
}
########################################
Regards,
David
perl -e'print for map chr$_+1,"111100113107044099117099132"=~/(.{3})/g'
------------------------------
Date: Mon, 31 Mar 2003 21:29:01 +0100
From: "Alex Banks" <alex@alexbanks.com>
Subject: Re: Removing Brackets
Message-Id: <3e88a512$0$21987$cc9e4d1f@news.dial.pipex.com>
"David" <perl-dvd@darklaser.com> wrote in message
news:A31ia.10$NY5.4073@news-west.eli.net...
> How about something like:
>
> ########################################
> $temp = cleanit($temp);
>
> sub cleanit {
> my $str = shift;
> $str =~ s/\([^\(\)]*?\)//g;
> $str = cleanit($str) if ($str =~ /\(.*\)/);
> return $str;
> }
> ########################################
David - absolutely spot on. Thanks so much.
Alex
---------------------------
http://www.alexite.com
------------------------------
Date: Mon, 31 Mar 2003 13:41:39 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: Replacing a string in a file
Message-Id: <SO0ia.28$3e4.51819@news.uswest.net>
Stephan Bour wrote:
> I'm having difficulties understanding file manipulation and I hope someone
> can help me.
> I'm trying to modify the text inside a hostfile and change the
> DNSSERVER=-NO- entry to DNSSERVER=-YES-.
[...]
To keep it simple, try a module designed to help you do this:
perldoc Tie::File
------------------------------
Date: Mon, 31 Mar 2003 14:54:42 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Re: Replacing a string in a file
Message-Id: <BAAE0732.6B9A%sbour@niaid.nih.gov>
in article SO0ia.28$3e4.51819@news.uswest.net, Jeff D Gleixner at
glex_nospam@qwest.net wrote on 3/31/03 14:41:
> Stephan Bour wrote:
>> I'm having difficulties understanding file manipulation and I hope someone
>> can help me.
>> I'm trying to modify the text inside a hostfile and change the
>> DNSSERVER=-NO- entry to DNSSERVER=-YES-.
> [...]
>
> To keep it simple, try a module designed to help you do this:
>
> perldoc Tie::File
>
Thanks, that should allow me to get started. However, my main goal is to
learn so I'd like to know whether you recommended the module because the
code to do what I need is too complicated to explain? If not, could you help
me with the basic steps?
Thank you,
Stephan.
------------------------------
Date: Mon, 31 Mar 2003 15:09:30 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: Replacing a string in a file
Message-Id: <d52ia.37$3e4.60272@news.uswest.net>
Stephan Bour wrote:
> in article SO0ia.28$3e4.51819@news.uswest.net, Jeff D Gleixner at
> glex_nospam@qwest.net wrote on 3/31/03 14:41:
>
>
>>Stephan Bour wrote:
>>
>>>I'm having difficulties understanding file manipulation and I hope someone
>>>can help me.
>>>I'm trying to modify the text inside a hostfile and change the
>>>DNSSERVER=-NO- entry to DNSSERVER=-YES-.
>>
>>[...]
>>
>>To keep it simple, try a module designed to help you do this:
>>
>>perldoc Tie::File
>>
>
>
> Thanks, that should allow me to get started. However, my main goal is to
> learn so I'd like to know whether you recommended the module because the
> code to do what I need is too complicated to explain? If not, could you help
> me with the basic steps?
> Thank you,
> Stephan.
>
It's not complicated, it's typically faster/easier to use modules that are
designed to do a particular task, when they're available.
You could use a one line script:
perl -pi -e s/DNSSERVER=-NO-/DNSSERVER=-YES-/g yourfile
If you want to do it step-by-step then you'd read through your file and
change each occurance and then write it.
Avoid reading the file into an array, there's no need.
It's also easier to write everything to a temporary file, then
rename it to your actual file, instead of using "+< file".
basic steps..
open file for read
open file2 for write
while reading file
substitute pattern1 for pattern2\
write line to temp file
close file
close file2
rename file2 to original file .. could comment this out in the beginning,
so you can check if the temp file is accurate before over-writing the
original file.
------------------------------
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 4795
***************************************