[14057] in Perl-Users-Digest
Perl-Users Digest, Issue: 1467 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 23 12:10:28 1999
Date: Tue, 23 Nov 1999 09:10:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <943377016-v9-i1467@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Nov 1999 Volume: 9 Number: 1467
Today's topics:
Opening and reading a HTML file from the web <c960334@student.dtu.dk>
Perl XS on VMS - linking to external libraries hohwy@my-deja.com
Re: Perl XS on VMS - linking to external libraries <dan@tuatha.sidhe.org>
perl2exe <hirop@hempseed.com>
Re: perl2exe (Clinton Pierce)
Re: perl2exe <samay1NOsaSPAM@hotmail.com.invalid>
Re: Refining code <nigh_postal@my-deja.com>
Signal Handler Seg Faulting epicycle@my-deja.com
Re: Simple help (Matthew Bafford)
Re: Simple help <sariq@texas.net>
Re: Simple help <lr@hpl.hp.com>
Re: Simple help (Matthew Bafford)
Re: Simple help <lr@hpl.hp.com>
Re: Test for eval() without using eval() ?? mkruse@netexpress.net
test locking <jim.mosier@usa.net>
Re: test locking <vetler@ifi.uio.no>
Re: what is the equivilant in perl? (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Nov 1999 17:30:58 +0100
From: Andrass Ziska Davidsen <c960334@student.dtu.dk>
Subject: Opening and reading a HTML file from the web
Message-Id: <383AC13F.9C180C2@student.dtu.dk>
--------------03EAED5B70BB1B31789B01F6
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
I would like to open a file located on the web, and read it as text. The
actual parsing of the file I think I can manage, but getting the file
itself is not obvious to me. I have tried to look at LWP::Simple and
HTTP::Request, but nothing in there seems to work.
On the system, these modules are not included, so I have installed them
onto a personal directory: ~/usr_bin/perlmod. But I have some problems
with the use/require call. (It returns something about not found in
@INC). I have also tried to include following line in my script, but
then get some other error messages, the line was:
BEGIN {push(@INC, "/gbar/newton/home4/c96/c960334/usr_bin/perlmod") ;}
Is there anybody, who can help me with this.
Thanks in advance.
regards
andrass
--
---oooOOOooo---
Andrass Ziska Davidsen
Fogedmarken 12, 2th
DK-2200 København N
DENMARK
cellular (+45) 28 14 49 99
URL1 http://www.gbar.dtu.dk/~c960334
e-mail mailto:c960334@student.dtu.dk
DTU-stud.no.: c960334
--------------03EAED5B70BB1B31789B01F6
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I would like to open a file located on the web, and read it as text. The
actual parsing of the file I think I can manage, but getting the file itself
is not obvious to me. I have tried to look at LWP::Simple and <A HREF="HTTP::Request">HTTP::Request</A>,
but nothing in there seems to work.
<p>On the system, these modules are not included, so I have installed
them onto a personal directory: ~/usr_bin/perlmod. But I have some problems
with the use/require call. (It returns something about not found in @INC).
I have also tried to include following line in my script, but then get
some other error messages, the line was:
<br> BEGIN {push(@INC, "/gbar/newton/home4/c96/c960334/usr_bin/perlmod")
;}
<p>Is there anybody, who can help me with this.
<p>Thanks in advance.
<p>regards
<p>andrass
<br>
<pre>--
---oooOOOooo---
Andrass Ziska Davidsen
Fogedmarken 12, 2th
DK-2200 København N
DENMARK
cellular (+45) 28 14 49 99
URL1 <A HREF="http://www.gbar.dtu.dk/~c960334">http://www.gbar.dtu.dk/~c960334</A>
e-mail <A HREF="mailto:c960334@student.dtu.dk">mailto:c960334@student.dtu.dk</A>
DTU-stud.no.: c960334</pre>
</html>
--------------03EAED5B70BB1B31789B01F6--
------------------------------
Date: Tue, 23 Nov 1999 14:53:04 GMT
From: hohwy@my-deja.com
Subject: Perl XS on VMS - linking to external libraries
Message-Id: <81e9oe$uls$1@nnrp1.deja.com>
Dear Newsgroup
Does anybody out there use Perl XS on VMS??
I have tried to get my XS extension to link on VMS by using the files
generated automatically for me via my Makefile.pl (or rather MakeMaker
via the parameters specified in Makefile.pl). Granted, before I spent x
amount of days trying to get this to generate me a linker options file
which included my object libraries external to the extension itself, I
should have read the note in the "perlvms - VMS-specific documentation
for Perl" stating: "... it does not yet recognize extra libraries
required to build shareable images which are not part of an extension,
so these must be added to the linker options file for the extension by
hand".... I had arrived at the same conclusion through trial and error,
but thinking I was at fault.
Does anybody know if this restriction has been lifted in a version
(same as or)later than: perl5_003_005??
Secondly, when I try to build perl on VMS, I run into exactly the same
problem (an XS extension relying on external object libraries) and thus
my VMS perl build fails miserably: Opcode.exe shareable image - missing
symbols: DEFSTASH, ENDAV, OP_MASK. According to the linker map these
symbols can be resolved if one includes DBGLIBPERL.OLB, module GLOBALS.
However, attempting to include this by hand produces a trillion
"multiply defined" symbols. I'm trying to build a DEBUG version on AXP
using the DECC compiler
Thirdly, is there a way (other than manually) to get XS on VMS to
automatically export the global symbols in your extension - to allow
outside perl modules to call the invidual extension entries?? So far, I
have found no way in which to do this, other than by manually adding
the symbols to the SYMBOL_VECTOR entry in my linker options file??
Finally, I wanted to use the SOCKET option of the perl build on VMS. I
run into a missing h-file: socketshr.h. Do I need to load this file off
the net? It neither seems to be a part of the perl distribution, nor of
the UCX installation on my cluster??
Sadly enough, the VMS OS seems doomed to go the way of other dinosaurs,
so many apologies if nobody out there has ever heard of this strange
animal. Thanks a bunch for any replies - in any event.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 Nov 1999 15:32:06 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl XS on VMS - linking to external libraries
Message-Id: <Wry_3.6050$Pj3.11562@news.rdc1.ct.home.com>
hohwy@my-deja.com wrote:
> Dear Newsgroup
> Does anybody out there use Perl XS on VMS??
Yep. Quite a bit, actually. (There are a dozen or so VMS XS modules on
CPAN, plus the ones, both generic and VMS-specific that come with perl
itself)
If you're using perl 5.005_03, there's a bug in MM_VMS.pm that causes
problems building extensions. There's a patch that went out on the VMS
Perl mailing list--you can get it from the archives at
http://www.xray.mpe.mpg.de/mailing-lists/vmsperl/
> I
> should have read the note in the "perlvms - VMS-specific documentation
> for Perl" stating: "... it does not yet recognize extra libraries
> required to build shareable images which are not part of an extension,
> so these must be added to the linker options file for the extension by
> hand".... I had arrived at the same conclusion through trial and error,
> but thinking I was at fault.
Well, sorta. Just adding them to the Makefile.PL is enough, just like on
Unix. That bit in perlvms is out of date and needs to be fixed.
> Does anybody know if this restriction has been lifted in a version
> (same as or)later than: perl5_003_005??
Please tell me that's really 5.005_03 transposed. If you're still using
5.003, toss it and upgrade.
> Secondly, when I try to build perl on VMS, I run into exactly the same
> problem (an XS extension relying on external object libraries) and thus
> my VMS perl build fails miserably: Opcode.exe shareable image - missing
> symbols: DEFSTASH, ENDAV, OP_MASK. According to the linker map these
> symbols can be resolved if one includes DBGLIBPERL.OLB, module GLOBALS.
> However, attempting to include this by hand produces a trillion
> "multiply defined" symbols. I'm trying to build a DEBUG version on AXP
> using the DECC compiler
This is really odd. You shouldn't need anything from any perl OLB, since
it's all in the PERLSHR.EXE shareable image. (It looks like you might be
using 5.003 after all. Ick)
> Thirdly, is there a way (other than manually) to get XS on VMS to
> automatically export the global symbols in your extension - to allow
> outside perl modules to call the invidual extension entries?? So far, I
> have found no way in which to do this, other than by manually adding
> the symbols to the SYMBOL_VECTOR entry in my linker options file??
No. Definitely not supported. You can call perl routines from an
extension, but you can't call one extension's routines from another, at
least not easily. If they're really XSubs, then you can do a perl_call_pv
to vector through perl's normal sub calling mechanism.
> Finally, I wanted to use the SOCKET option of the perl build on VMS. I
> run into a missing h-file: socketshr.h. Do I need to load this file off
> the net? It neither seems to be a part of the perl distribution, nor of
> the UCX installation on my cluster??
It's part of a third-party library. As of perl 5.003, there was no
'standard' berkeley socket library provided as part of VMS or Dec C.
That's long-since changed (with either 5.004 or 5.004_01) and you can use
the berkeley interface that comes standard with Dec C 5.0 and up.
There's a link to socketshr off of http://www.sidhe.org/vmsperl someplace
if you really want it, though you'd be better off snagging
http://cpan.perl.org/src/latest.tar.gz and building a fresh, clean,
up-to-date perl.
> Sadly enough, the VMS OS seems doomed to go the way of other dinosaurs,
> so many apologies if nobody out there has ever heard of this strange
> animal. Thanks a bunch for any replies - in any event.
Oh, good grief. Such fatalism's unwarranted--VMS is not in any way doomed.
But that's a rant for another newsgroup. The fact that VMS is one of the
core platforms perl builds on should be at least cause for a little
optimism.
Most of your problems (probably all of 'em) are due to an old version of
perl. The current version's had these problems fixed. (And yes, I do know
that 5.003's still on the freeware CD. We're working on that)
Dan
------------------------------
Date: Tue, 23 Nov 1999 15:06:11 +0100
From: "Coke WebMoonster }:-[" <hirop@hempseed.com>
Subject: perl2exe
Message-Id: <383A9F53.8023892F@hempseed.com>
Hi,
Do somebody know if there is a FAQ or HOWTO for
perl2exe??
------------------------------
Date: Tue, 23 Nov 1999 14:46:12 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: perl2exe
Message-Id: <383da870.897644204@news.ford.com>
[poster cc'd in e-mail]
On Tue, 23 Nov 1999 15:06:11 +0100, "Coke WebMoonster }:-["
<hirop@hempseed.com> wrote:
>Hi,
>Do somebody know if there is a FAQ or HOWTO for
>perl2exe??
Gee, feeding "perl2exe" to a couple of search engine yeilds LOTS of hits
with information.
I suppose you need an FAQ or a HOWTO for using the web, too?
--
Clinton A. Pierce "If you rush a Miracle Man, you
clintp@geeksalad.org get rotten Miracles." -- Miracle Max,
http://www.geeksalad.org The Princess Bride
------------------------------
Date: Tue, 23 Nov 1999 07:39:45 -0800
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Re: perl2exe
Message-Id: <000b8d9b.2c60feeb@usw-ex0102-016.remarq.com>
visit www.perl2exe.com
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 23 Nov 1999 14:55:00 GMT
From: nigh_postal <nigh_postal@my-deja.com>
Subject: Re: Refining code
Message-Id: <81e9s1$un6$1@nnrp1.deja.com>
In article <xkf7ljaxgfv.fsf@valdemar.col.hp.com>,
Eric The Read <emschwar@rmi.net> wrote:
> nigh_postal <nigh_postal@my-deja.com> writes:
> > However, this causes some problems in that the ${$fields[$i]}
returns a
> > global variable.
>
> Not exactly. It is what we call a "symbolic reference", and is a Bad
> Thing(tm). See a recent post in the "Is $$variable allowed like in
PHP ?"
> thread by Mark-Jason Dominus for a series of good reasons why.
>
Thanks Eric. I understand that it would be better to use a hash to
store the fields, and I have even done so in the past (for minor parts
of the programs), it was just that to make the use of hashes program-
wide (2000+ lines), it would require a great deal more typing. {$fields
[$i]} turns into $tmp{$fields[$i]}, and thus to retrieve an individual
field it is $tmp{'NDX_NAME'} instead of $NDX_NAME. A pain when you
have 7 different database structures with 20 fields each :P Of course,
database design is the next thing I would like to review. I have
geared my code towards speed of production at the expense of database
design, and I am sure there is a way to clean up the databases without
slowing myself down too much.
Although I personally have never had any problems debugging the code
because of my use of symbolic references, I realize that in the future
it may be somebody else who is modifying my code who has no clue what
to watch out for. So in that respect it would be a good idea to move
to the hash. I am also looking into the possibility of moving to an OO
version of the program, but as of yet I am not familiar enough with it
to warrant an attempt.
Thanks,
-Cody
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 Nov 1999 15:58:05 GMT
From: epicycle@my-deja.com
Subject: Signal Handler Seg Faulting
Message-Id: <81edi9$1ov$1@nnrp1.deja.com>
Hello All,
I am having a problem with my perl signal handler. I am catching the
signal TERM in a solaris 5.6 environment running perl 5.005_02. In the
signal handler I need to save the current state of the application and
save a counter to a file before it exits. I am the one sending the
signal from a shell script to the perl process so I have complete
control over that. Is there a better way to do this, maybe handle it a
different way? Right now the signal goes through and in the signal
handler it gets to different parts of the code before it Segmentation
Faults and core dumps. It does not do this when you run them both from
a command line and I sent the kill from the command line but it appears
to happen when the kill is sent from a shell script. Am I going about
this wrong? Can someone shine some light on signal handlers and maybe
suggest another way of telling a perl process to shut down cleanly?
Thanks,
Sean
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 Nov 1999 14:30:02 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Simple help
Message-Id: <slrn83l80g.29n.*@dragons.duesouth.net>
23 Nov 1999 12:35:58 GMT, a great smashing of the head occured against
Jonathan Stowe <gellyfish@gellyfish.com>'s keyboard, causing
alt.perl,comp.lang.perl.misc to receive this:
: In comp.lang.perl.misc MC <mcts@backwoods.org> wrote:
: > Larry Rosler wrote:
: >> / 99(\d+)\s+(.+\S) +\d/ and print "|99$1 $2|\n";
: > / 99(\d+)\s+(.+\S) +\d+/ and print "|99$1 $2|\n";
:
: I might be going stupid here but isnt that what Larry said ?
Nope.
: /J\
--Matthew
------------------------------
Date: Tue, 23 Nov 1999 09:21:44 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: Simple help
Message-Id: <383AB108.88E7827B@texas.net>
Larry Rosler wrote:
>
> In article <38395658.76641CF@texas.net> on Mon, 22 Nov 1999 08:42:32 -
> 0600, Tom Briles <sariq@texas.net> says...
> >
> > Any graceful ideas on how to strip the trailing whitespace, without an
> > additional loop through the hash/array, are welcome.
>
> #!/usr/local/bin/perl -w
> use strict;
>
> $_ = ' 9912345 John Q. Public III 87';
>
> / 99(\d+)\s+(.+\S) +\d/ and print "|99$1 $2|\n";
Neato benito!
A couple of questions, though:
1) Why use '\S' instead of '?' ?
2) Why do you hardcode the '99' in the 'print' statement, rather than
including it in '$1' ?
- Tom
------------------------------
Date: Tue, 23 Nov 1999 07:53:29 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Simple help
Message-Id: <MPG.12a4585573e1364a98a25a@nntp.hpl.hp.com>
In article <slrn83l80g.29n.*@dragons.duesouth.net> on Tue, 23 Nov 1999
14:30:02 GMT, Matthew Bafford <*@dragons.duesouth.net> says...
> 23 Nov 1999 12:35:58 GMT, a great smashing of the head occured against
> Jonathan Stowe <gellyfish@gellyfish.com>'s keyboard, causing
> alt.perl,comp.lang.perl.misc to receive this:
> : In comp.lang.perl.misc MC <mcts@backwoods.org> wrote:
> : > Larry Rosler wrote:
> : >> / 99(\d+)\s+(.+\S) +\d/ and print "|99$1 $2|\n";
> : > / 99(\d+)\s+(.+\S) +\d+/ and print "|99$1 $2|\n";
> :
> : I might be going stupid here but isnt that what Larry said ?
>
> Nope.
Would an example of a string that matches one regex but not the other
put this discussion to rest? Anyone?
I take a few hours off to sleep, and this place goes to hell. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Nov 1999 16:30:05 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Simple help
Message-Id: <slrn83leqo.2ue.*@dragons.duesouth.net>
Larry Rosler:
: Matthew Bafford:
: > Jonathan Stowe:
: > : MC:
: > : > Larry Rosler wrote:
: > : >> / 99(\d+)\s+(.+\S) +\d/ and print "|99$1 $2|\n";
: > : > / 99(\d+)\s+(.+\S) +\d+/ and print "|99$1 $2|\n";
: > :
: > : I might be going stupid here but isnt that what Larry said ?
: >
: > Nope.
:
: Would an example of a string that matches one regex but not the other
: put this discussion to rest? Anyone?
Oh, I know the two match the same strings. But no, that's not what you
said. :)
: I take a few hours off to sleep, and this place goes to hell. :-)
We need you, Larry!
: (Just Another Larry) Rosler
--Matthew
------------------------------
Date: Tue, 23 Nov 1999 08:53:59 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Simple help
Message-Id: <MPG.12a46682bd6034dd98a25c@nntp.hpl.hp.com>
In article <383AB108.88E7827B@texas.net> on Tue, 23 Nov 1999 09:21:44 -
0600, Tom Briles <sariq@texas.net> says...
> Larry Rosler wrote:
...
> > $_ = ' 9912345 John Q. Public III 87';
> >
> > / 99(\d+)\s+(.+\S) +\d/ and print "|99$1 $2|\n";
>
> Neato benito!
Aw, shucks! 'Tweren't nuffin.
> A couple of questions, though:
>
> 1) Why use '\S' instead of '?' ?
Ok. Also, why did I use '\s' once, instead of ' '? I dunno. It was
late.
> 2) Why do you hardcode the '99' in the 'print' statement, rather than
> including it in '$1' ?
Q: What is the difference between a duck?
A. Each leg is both the same.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Nov 1999 16:34:29 GMT
From: mkruse@netexpress.net
To: abigail@delanet.com
Subject: Re: Test for eval() without using eval() ??
Message-Id: <81efml$3n0$1@nnrp1.deja.com>
In article <slrn83jm7c.m2v.abigail@alexandra.delanet.com>,
abigail@delanet.com wrote:
> DO NOT POST IN REVERSE ORDER AND DO NOT QUOTE THE ENTIRE ARTICLE,
> INCLUDING SIGNATURE, MORON.
Wow, what a bitch you are.
My newsreader which I do not normally use did this and I didn't notice.
I wonder how much better it is to write in all caps and hurl flames?
> || This is not a workable solution from within a perl script,
unfortunately.
> Sure it is.
> #!/opt/perl/bin/perl -w
> use strict;
> print "Nope\n" if `perl -e "eval()" 2>&1` =~ /Undefined/;
> __END__
It's technically possible, but not a workable solution. If the web
server disables eval() it most certainly disables back-ticks and system
().
> || (and it doesn't work from NT, either)
> Eh? Why not?
Because not every OS works exactly how you want it to.
> Just install a Bourne shell look-alike for NT.
> [And before you complain "my provider doesn't have such a shell",
> that's to frigging bad. If you choose a provider that gives you NT,
> but without a decent shell, and a crippled Perl, that's your problem,
> not ours. Pick a better provider.]
I often wonder what happened to people like you in childhood to lead to
such a pissy attitude.
My question is for CGI scripts which will be distributed to many
people. I do not have control over their environment. Telling them to
install certain tools is not an option. I write code that is designed
to run without any dependencies at all.
> || I would like a way to do this without spawning a new perl process
and
> || trapping the output, if it exists.
> Well, aren't you getting a bit picky? You don't want to use eval, you
> don't want to spawn processes... what's next, you want to do it
without
> using vowels?
A simple "I don't know how to do this" would have sufficed. If my needs
are too complex for you to understand, just don't respond.
In fact, please put me on your auto-kill list if you have one, so you
never have the urge to respond to my postings again.
Thanks.
--
Matt Kruse
mkruse@netexpress.net
http://mkruse.netexpress.net/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 Nov 1999 15:08:07 GMT
From: "Jim Mosier" <jim.mosier@usa.net>
Subject: test locking
Message-Id: <r5y_3.3000$QT2.16271@pm02news>
I'm fairly new to Perl, but want to use file locking and then test that if
something is locked.
program 1:
------------------
lock the file for read/write/whatever
do something
unlock it
program 2:
----------------
while( when able to open the file ) {
lock
do something..
unlock
}
------------------------------
Date: 23 Nov 1999 16:48:19 +0100
From: Vetle Roeim <vetler@ifi.uio.no>
Subject: Re: test locking
Message-Id: <yayyabpgqf0.fsf@hogni.ifi.uio.no>
* Jim Mosier
> I'm fairly new to Perl, but want to use file locking and then test that if
> something is locked.
>
> program 1:
> ------------------
> lock the file for read/write/whatever
> do something
> unlock it
>
> program 2:
> ----------------
> while( when able to open the file ) {
> lock
> do something..
> unlock
> }
Is this what you're looking for? (from 'man perlfun')
flock FILEHANDLE,OPERATION
Calls flock(2), or an emulation of it, on
FILEHANDLE. Returns TRUE for success, FALSE on
failure. Produces a fatal error if used on a
machine that doesn't implement flock(2), fcntl(2)
locking, or lockf(3). flock() is Perl's portable
file locking interface, although it locks only
entire files, not records.
OPERATION is one of LOCK_SH, LOCK_EX, or LOCK_UN,
possibly combined with LOCK_NB. These constants are
traditionally valued 1, 2, 8 and 4, but you can use
the symbolic names if import them from the Fcntl
module, either individually, or as a group using the
':flock' tag. LOCK_SH requests a shared lock,
LOCK_EX requests an exclusive lock, and LOCK_UN
releases a previously requested lock. If LOCK_NB is
added to LOCK_SH or LOCK_EX then flock() will return
immediately rather than blocking waiting for the
lock (check the return status to see if you got it).
..
vr
--
Vetle Roeim
Departement of Informatics, University of Oslo, Norway
f u cn rd ths u r prbly a gk
------------------------------
Date: Tue, 23 Nov 1999 06:23:00 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: what is the equivilant in perl?
Message-Id: <slrn83ku8k.b0e.tadmc@magna.metronet.com>
On Tue, 23 Nov 1999 11:50:22 GMT, Peter Lavender <plaven@idl.net.au> wrote:
>I'm having a few problems grasping the concepts of regular expressions and
>how to get what I'm looking for, mostly from log files.
>
>For example the following line get's the IP address for me from
>/var/log/messages:
>
>ISPIP=`cat /var/log/messages | grep 'local IP address' | awk '{print $9 }'
>| tail -n 1`
>
>I can't get my mind around doing the same with a perl script and I think
>it's all down to how to use regular expressions to do the above.
--------------------------
#!/usr/bin/perl -w
use strict;
my $lastip;
open(LOG, '/var/log/messages') || die "could not open '/var/log/messages' $!";
while (<LOG>) {
$lastip = (split)[8] if /local IP address/;
}
close(LOG);
print "$lastip\n";
--------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 1467
**************************************