[11421] in Perl-Users-Digest
Perl-Users Digest, Issue: 5020 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 1 13:07:37 1999
Date: Mon, 1 Mar 99 10:02:02 -0800
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, 1 Mar 1999 Volume: 8 Number: 5020
Today's topics:
Re: grep netstat and display status in html. <gellyfish@btinternet.com>
Re: grep netstat and display status in html. (ICG)
Re: grep syntax question (Larry Rosler)
Re: Help - regex to extract two fields in "uptime" <baillie@my-dejanews.com>
Re: Help!! (Larry Rosler)
Re: Help!! <jdf@pobox.com>
Re: Help!! <clm@biteme.com>
Re: HELP: Am 100% lost on these error msgs <rick.delaney@home.com>
Re: HELP: Am 100% lost on these error msgs (Ronald J Kimball)
Re: How to Read/Block/Write a file at same time <jdf@pobox.com>
Re: HTML links from perl (ICG)
Java and Perl question <wdacruz@concentric.net>
localtime -> time johan.levin@mbox300.swipnet.se
Re: localtime -> time (Honza Pazdziora)
Re: localtime -> time (Larry Rosler)
Matching (newbie) <no_amaring@jps.net>
matching multiple times and remembering each match (Eric Smith)
Re: MIME attachements. General questions. (Eric Smith)
Re: Newbie question (Abigail)
Re: newbie: How couuld I find my IP? <gellyfish@btinternet.com>
Re: newbie: How couuld I find my IP? <bodycount@mail.jps.net>
Re: Non-greedy regex efficiency (Ronald J Kimball)
Numeric Sort golfer@usa.net
Re: Numeric Sort (Larry Rosler)
Re: Offtopic (Was: Re: custom dial script - simple if y <gellyfish@btinternet.com>
Re: open file problem <hm@garmisch.net>
Re: PC - UNIX text converter <coyote38@pacbell.net>
Re: Perl script to compare files (Abigail)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Feb 1999 04:21:48 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: grep netstat and display status in html.
Message-Id: <7bag8s$4bk$1@gellyfish.btinternet.com>
On Sat, 27 Feb 1999 19:50:03 -0600 Chris Gebhardt wrote:
> I am a perl newbie trying to have a perl script post a message if
> netstat returns a default gateway.
<snip>
>
> #!/usr/bin/perl
> unless (fork){
> exec "netstat -r |grep default >/home/httpd/cgi-bin/IP";
> }
> wait;
>
> if (-z "IP"){
> print 'Content-type: text/html
> <HTML>
> Not Connected
> </HTML>
> ';
>
> } else {
> print 'Content-type: text/html
> <HTML>
> CONNECTED
> </HTML>';
> }
>
> unless (fork){exec "rm -f IP";}
I think that the majority of what you are doing there is unnecessary
you could try (caveat untested):
use CGI qw(:standard);
print header(),start_html('Blah');
if (grep /default/,`netstat -r`)
{
print "Connected";
}
else
{
print "Not Connected";
}
print end_html();
I have probably got the sense of that the wrong way round but it is
three^H^H^H^H^Hfour in the morning.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 01 Mar 99 03:18:50 GMT
From: postmaster@UU.NET (ICG)
Subject: Re: grep netstat and display status in html.
Message-Id: <7bd4n4$bdu@world6.bellatlantic.net>
In article <36D8A0CB.8551C0BB@enteract.com>, cjgebha@enteract.com wrote:
>I am a perl newbie trying to have a perl script post a message if
>netstat returns a default gateway.
>Basically I grep netstat -r for the word default and direct the output
>of the file to a file called IP. Well when I run the perl from the
>command line it creates the correct output but when i try it in the
>webpage it returns a internal server error and never creates the file.
>I have tried almost everything to debug this script but I can not seem
>to get any to work.
<stuff deleted>
When ever I run a Linux command from Perl I capture all the output in a
variable and then parse it, looking for the data I want. Then I throw the
rest away. I know it's a little inefficent, but it works for me.
# Go finger the NAS machines --------------
$fingermax = `/usr/bin/finger \@XXX.XXX.XXX.XXX`;
$fingermed = `/usr/bin/finger \@XXX.XXX.XXX.XXX`;
(Note: substitute your desired Ip for the X's)
Later...
# Andesite user tally --------------
@lineA = split(/\n/,$fingermax);
$andesitecount = 0;
$testA = "XXX";
for ($loopA=0; $loopA <= $#lineA; $loopA++){
if (@lineA[$loopA] =~ m/$testA/g) {
$andesitecount++ ;
}
}
$andesitecount = $andesitecount-1;
This gives me a count of the active users on a Max Ascend. The XXX on the
$testA variable should be set to the leading octet of the IP address that the
users are assigned. This is becuse the output from the finger gives a lot of
stuff, and I had to dig through it to ID an active user line.
Anyway, back to the problem. I don't know if it will help, but I get errors
if I don't set the whole command in ' . I noticed yours were in " , so you
might try that.
------------------------------
Date: Sun, 28 Feb 1999 07:55:46 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: grep syntax question
Message-Id: <MPG.114306df60bb1e5f9896ae@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <19990228063544.11949.00002324@ng-cg1.aol.com>, on 28 Feb
1999 11:35:44 GMT klmn2@aol.com says...
> ... If I search for the word "book" and in the file being searched it says
> "Book" - it will say no results found. But it I search for "Book" it will say
> it was found. I have tried things like:
> @results = grep(/$searchstr/i,@mydata);
> @results = grep(/(?i)$searchstr/,@mydata);
And why didn't either of them do *exactly* what you wanted?
Please show us a small demonstration of a failure -- most unlikely,
because this is very basic Perl.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 Mar 1999 16:46:59 GMT
From: Baillie <baillie@my-dejanews.com>
Subject: Re: Help - regex to extract two fields in "uptime"
Message-Id: <7bega0$nus$1@nnrp1.dejanews.com>
Sorry, skipped past the regexp part..
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 28 Feb 1999 08:16:42 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help!!
Message-Id: <MPG.11430bbc8e88ea639896b0@nntp.hpl.hp.com>
In article <ORE4J6uY#GA.119@nih2naad.prod2.compuserve.com>, on Sun, 28
Feb 1999 02:45:04 -0500 clm@biteme.com says...
> I am writing my first Perl script, which is a simple looping translation
> program, or so I thought until I actually wrote it.
> The problem I encountered is that I want to replace a number of expressions
> that literally begin with plus signs that are present in the data I am
> translating. Unfortunately for me, the plus signs are interpreted as regexp
> characters. How do I get around this?
<SNIP> of program with *hundreds* of lines of a data-conversion table,
in a post with a useless Subject! Help!! indeed...
Read some basic documentation (in perlre) about regex metacharacters and
how to escape them. In particular, look for \Q and for the function
quotemeta.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 28 Feb 1999 11:43:06 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Clawed Le Mew" <clm@biteme.com>
Subject: Re: Help!!
Message-Id: <m3aexyxyw5.fsf@joshua.panix.com>
"Clawed Le Mew" <clm@biteme.com> writes:
> The problem I encountered is that I want to replace a number of
> expressions that literally begin with plus signs that are present in
> the data I am translating. Unfortunately for me, the plus signs are
> interpreted as regexp characters. How do I get around this?
You didn't need to post hundreds of lines of code for that. If you
post code here, it should be *just enough* to illustrate your text.
To represent a regex meta-character as itself you simply prepend a
backwhack to it, as documented in perlre.
/\+/; # match a literal plus-sign.
If you'd like to escape all of the meta-characters in a string, you
may use the quotemeta() function or the "\Q\E" escapes, also
documented in perlre and perlfunc.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 1 Mar 1999 00:10:29 -0500
From: "Clawed Le Mew" <clm@biteme.com>
Subject: Re: Help!!
Message-Id: <e8Tc8H6Y#GA.290@nih2naae.prod2.compuserve.com>
The \Q and \E escape within the first part of the substitute expression were
the appropriate solution for me. These were special character codes that
were nonstandard (from an old IBM mainframe "database" [though I hesitate to
use that word to describe it]) that I am replacing with codes that are XML
entities if possible or, where this is not possible, some close
approximation thereof.
Steven Lembark wrote in message <36DA0C6A.153C2D80@wrkhors.com>...
>escape the sequences. can be done for you by perl. that or
>remove them from the input stream before using the s/// section
>via substr or another regeular expression.
>
>--
> Steven Lembark 2930 W. Palmer St.
> Workhorse Computing Chicago, IL 60647
> lembark@wrkhors.com 800-762-1582
>---------------------------------------------------------------------
> The opinions expressed here are those of this company.
> I am the company.
>---------------------------------------------------------------------
------------------------------
Date: Mon, 01 Mar 1999 04:35:03 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: HELP: Am 100% lost on these error msgs
Message-Id: <36DA1AD9.9F57681A@home.com>
[posted & mailed]
David Combs wrote:
>
> Am at my wits end.
>
> I learned at least to use STDERR, which seems to automatically
> "flush" the line before the err msgs come out.
>
> Does anything stand out as being a problem?
I wouldn't say it stands out when you post over 400 lines of code.
Sheesh.
[snip]
> Use of uninitialized value at test-flipflop9.pl line 386, <FIN> chunk 1 (#1)
Okay, so maybe you should have pointed out line 386.
[snip]
>
> DEBUG: NEW LINE, at L1, is: ""
> Use of uninitialized value at test-flipflop9.pl line 387, <FIN> chunk 1 (#1)
>
> Undefined subroutine &main::processThisline called at test-flipflop9.pl line
> 390, <FIN> chunk 1 (#2)
And up to line 390. Let's find this chunk.
[snip snip snip snip snip]
> while (defined($curLine = <$myVarHoldingFIN>)) { # START-WHILE:
>
> print STDERR "DEBUG: NEW LINE, at L", "$., is: \"$_\"\n"; #27feb99
You're printing $_, but I don't see where you're initializing it. Maybe
you should be printing $curLine?
> chomp;
Maybe this should be
chomp $curLine;
?
> $prevCurLine = $curLine; #debug only: dkc added 26feb99.
>
> processThisline(); # ----------- CALL TO "PROCESS THIS LINE()".
You are told that this subroutine is undefined. That's a sure sign of
spelling errors. Sure enough, the real name is 'processThisLine' (with
a capital "L").
To avoid this you might want to abandon your crazy mixedCaseNaming for
the more Perlish underscores_as_spaces_naming.
Also, I took a quick glance at processThisLine and it appears that you
are trying to access the global $_ in there. Is it really meant to
process the current line? If so then you should pass the line as an
argument.
my $return_value = process_this_line($current_line);
sub process_this_line {
my $line = $_[0];
# processing here
}
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 28 Feb 1999 23:46:14 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: HELP: Am 100% lost on these error msgs
Message-Id: <1dnym9o.al9uk61i3jzewN@bay2-340.quincy.ziplink.net>
[posted and mailed]
David Combs <dkcombs@netcom.com> wrote:
Error #1:
> Use of uninitialized value at test-flipflop9.pl line 386, <FIN> chunk 1 (#1)
> $curLine = "";
> while (defined($curLine = <$myVarHoldingFIN>)) { # START-WHILE:
>
> print STDERR "DEBUG: NEW LINE, at L", "$., is: \"$_\"\n"; #27feb99
> chomp;
You are reading input into $curLine, but you try to print $_. The value
of $_ is uninitialized. You then attempt to chomp $_. The value of $_
is still uninitialized.
Error #2:
> Undefined subroutine &main::processThisline called at test-flipflop9.pl line
> 390, <FIN> chunk 1 (#2)
> sub processThisLine { # STARTOF: sub processThisLine:::
You defined a subroutine named processThisLine, with a capital L. You
called a subroutine named processThisline, with a lowercase L. Capisce?
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 01 Mar 1999 12:04:53 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: dragnovich@my-dejanews.com
Subject: Re: How to Read/Block/Write a file at same time
Message-Id: <m3ogmdjg3u.fsf@joshua.panix.com>
dragnovich@my-dejanews.com writes:
> Hello .. is the there any way to open a file.. and keep it opened
> (so no body can read/write it, until I close the file) read file
> data modify data and write the new data in the same file??
No! [Said in the same spirit as when Gandalf is asked whether he knows
the password to the door of Moria.]
However, you *can* lock the file so that any other process that also
locks the file will wait until you've closed it before proceeding.
perlfaq5 deals with this topic, and there are several examples in the
wonderful _Perl Cookbook_, published by O'Reilly.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 01 Mar 99 03:02:38 GMT
From: postmaster@UU.NET (ICG)
Subject: Re: HTML links from perl
Message-Id: <7bd3op$bdu@world6.bellatlantic.net>
In article <919973343.27062.0.nnrp-03.c1edd369@news.demon.co.uk>, "Pete Robinson" <PRobinson@microdot99.demon.co.uk> wrote:
>I have a lot of pages to serve which are all based on the same format.
>
>I would like to use a perl script to get input from a text file detailing
>body text and locations of image files to be inserted.
>
>This should be pretty easy to implement - but how can I put hyperlinks in to
>pages which the script hasn't yet generated?
>
>To clarify, the pages refer to different properties. The parent page has one
>external photo and three internals.
>The idea is that when one of the small images is clicked it links to a page
>with a larger version of the image - any ideas?
Add something like to following in the HTML printout part of your script
<a HRef="bigpicture.jpg"><img src="littlepicture.jpg" alt="Picture of a thing"
lowsrc="reallybadlittlepicture.jpg"></a>
Of course, put the proper server/path names in it so the browser can get to
the picture.
------------------------------
Date: 27 Feb 1999 22:00:06 PST
From: "Walter G. da Cruz" <wdacruz@concentric.net>
Subject: Java and Perl question
Message-Id: <36D4CF50.31140C23@concentric.net>
Hi:
I am looking for some points how to use Perl inside my java program.
I've been told that I should use JPL, which is included in the latest
perl version. I just installed perl 5.005_55 dev. in my linux box
(RedHat 5.2 kernel 2.036) but I couldn't find any information how to
use JPL. Any help will be appreciated.
Please, reply to my personal e-mail: wdacruz@concentric.net I'm not
subscribed to this newsgroup.
Walter
------------------------------
Date: Sun, 28 Feb 1999 15:46:46 GMT
From: johan.levin@mbox300.swipnet.se
Subject: localtime -> time
Message-Id: <7bbod5$iui$1@nnrp1.dejanews.com>
Hi!
I'm making a perl script that parses my syslog-file.
There are times that I want to convert to "seconds-since-1970".
There are two functions to convert from seconds-since-1970 to human-readable,
but I haven't found an easy way to convert in the other direction.
Is there a similar builtin for this (that I can't find) or do I have to do
it manually?
TIA
/Johan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 28 Feb 1999 16:33:43 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: localtime -> time
Message-Id: <F7vI07.L0D@news.muni.cz>
On Sun, 28 Feb 1999 15:46:46 GMT, johan.levin@mbox300.swipnet.se <johan.levin@mbox300.swipnet.se> wrote:
>
> Is there a similar builtin for this (that I can't find) or do I have to do
No.
> it manually?
No.
Install the Date::Parse module from CPAN and use the str2time
function. The module comes with a nice man page. To install in, use
$ perl -MCPAN -e shell
cpan> install Date::Parse
Hope this helps,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
make vmlinux.exe -- SGI Visual Workstation Howto
------------------------------------------------------------------------
------------------------------
Date: Sun, 28 Feb 1999 08:37:58 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: localtime -> time
Message-Id: <MPG.114310c4d648fa3d9896b1@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7bbod5$iui$1@nnrp1.dejanews.com>, on Sun, 28 Feb 1999
15:46:46 GMT johan.levin@mbox300.swipnet.se says...
> I'm making a perl script that parses my syslog-file.
> There are times that I want to convert to "seconds-since-1970".
>
> There are two functions to convert from seconds-since-1970 to human-readable,
> but I haven't found an easy way to convert in the other direction.
>
> Is there a similar builtin for this (that I can't find) or do I have to do
> it manually?
There are several important things that one has to do manually, but this
is not among them. Oh -- you meant without writing your own function?
Indeed.
Assuming you can easily break your data down into the components of date
and time, the functions Time::timelocal or Time::timegm will do what you
want. There is also a *short* function that you can copy from the new
Perl Function Repository at
<URL:http://moiraine.dimensional.com/~dgris/cgi-
bin/pfr?index=1&func=UTC_to_Epoch> (shameless advertisement).
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 27 Feb 1999 20:53:24 -0800
From: "amaring" <no_amaring@jps.net>
Subject: Matching (newbie)
Message-Id: <36d94123.0@news1.jps.net>
I need to figure out if a string has any non alphanumeric characters in it.
Unfortunately, the one thing I do not have a good grasp on is the type of
pattern matching that is required. Someone want to please explain this one
to me?
Thanks
------------------------------
Date: 28 Feb 1999 16:44:06 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: matching multiple times and remembering each match
Message-Id: <slrn7ditfs.7f9.eric@plum.fruitcom.com>
Hello
I have a script that matches strings in the input file and then needs to
print out those matches at the end. A complicating factor is that the
strings may traverse the standard input fields seperator -> `\n'. So i use
the following construction (which works):
undef $/;
$_ = (<>);
if ($_ =~ s/tagA(matchedstring)tagB//g) {
push(@contents,$1); # (<- I think the syntax is ok here)
}
<snip>
print @contents;
Now, I need to accomodate thos instances when there may be more than one
occurance of tagA(matchedstring)tagB. Problem is that the $1 keeps getting
reset so that only the final instance of the match is left in $1. My
effort above tries to stack the @contents array with all the $1 matches as
they occu, but it seems that perl parses the file in one go with this
construct and does not iterate like a `for' or `while' loop - the debugger
confirms that.
Any ideas how I can (hopefully with minor surgery) remember each match.
TIA
Eric Smith
<eric@fruitcom.com>
------------------------------
Date: 28 Feb 1999 16:25:19 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: Re: MIME attachements. General questions.
Message-Id: <slrn7discl.7f9.eric@plum.fruitcom.com>
Hi
Lets be sociable and use other tools as well, so If you are prepared to
leave perl out of this part of your task, then I recommend using uudeview.
This is how I have implemented it in my .procmailrc. he nice thing about
it is the preservation of the original file name and so far perfect and
painless extraction and decoding of attachments of whatever flavour.
This procmail command places the extracted file _correctly named_ in the
dir /d/marketdata/USKO01/. It then runs your perl script. I use a silly
trick for the script to always act on the mosdt recent file in the dir.
* ^From:.john@fruit.com
:0 c
|/usr/local/bin/uudeview -i -p /d/marketdata/USKO01/ - ; \
/home/eric/bin/script.pl
HTH
Eric Smith
<eric@fruitcom.com>
>
> The part that does not work is I can't seem to figure out how to
> determin the file name of the attached file using MIME tools. I have
------------------------------
Date: 28 Feb 1999 05:02:34 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Newbie question
Message-Id: <7baila$rn5$5@client2.news.psi.net>
johan.levin@mbox300.swipnet.se (johan.levin@mbox300.swipnet.se) wrote on
MMVI September MCMXCIII in <URL:news:7b96of$jmm$1@nnrp1.dejanews.com>:
() Hi
()
() I've only just started to learn perl.
()
() I understand these lines should do the same thing:
()
() <STDIN>
() $_ = <STDIN>
()
() But they don't. (Actually I don't understand what the first one does at all.)
Indeed. Assigning to $_ only happens in a while ():
while (<STDIN>) {
...
}
is equivalent to
while (defined ($_ = <STDIN>)) {
...
}
I guess it wouldn't have been unreasonable to have <FILE_HANDLE> in void
context assign to $_, but changing that now would break to many programs.
Of course, one could tie the handle and assign to $_ when fetched in
a void context!
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: 28 Feb 1999 04:08:00 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: newbie: How couuld I find my IP?
Message-Id: <7baff0$4be$1@gellyfish.btinternet.com>
On Sat, 27 Feb 1999 19:12:28 -0800 Mark Davis wrote:
> I'm hooked up to an ISP with a PPP connection and I want to know what my
> IP is. Where should I look.
>
> I know that I can do a system call to ifconfig but that seems like
> a dumb way to do it. Plus I need this to run as a cron job and I just
> learned that STDOUT ends up going to mail from cron...
For myself I discover my current IP number from the parameters to the
'ip-up' script that is executed by pppd when the connection is made.
But of course that is little to do with Perl (actually my 'ip-up' is a
Perl program but it neednt be).
Other than that you probably are just as well to parse the output of
ifconfig if you are not confident with the socket functions.
BTW you can always redirect the output of some cron run program somewhere
else so it doesnt get mailed.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 27 Feb 1999 23:00:26 -0800
From: Mark Davis <bodycount@mail.jps.net>
Subject: Re: newbie: How couuld I find my IP?
Message-Id: <36D8E98A.B5F1BC3C@mail.jps.net>
Jonathan Stowe wrote:
> For myself I discover my current IP number from the parameters to the
> 'ip-up' script that is executed by pppd when the connection is made.
> But of course that is little to do with Perl (actually my 'ip-up' is a
> Perl program but it neednt be).
>
Need to look into this one... is was pretty late when I got my pppd
working so I need to look around there :)
> Other than that you probably are just as well to parse the output of
> ifconfig if you are not confident with the socket functions.
>
I'm working on the sockets approach... Not to sure about that yet.
> BTW you can always redirect the output of some cron run program somewhere
> else so it doesnt get mailed.
Now how would I do that? So far all of the system calls fro a perl
script executed by cron have come up empty. Is there something I can put
in the crontab? I have done "ifsetup >foo.txt" and system ("ifsetup
>foo.txt"); in both cases, foo.txt is created with 0 bytes.
Really lost on this...
Thanks again
--mark
------------------------------
Date: Sat, 27 Feb 1999 16:34:52 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Non-greedy regex efficiency
Message-Id: <1dnw7ta.xzwszguv3m5oN@bay1-409.quincy.ziplink.net>
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to Ronald J Kimball
> <rjk@linguist.dartmouth.edu>],
> who wrote in article <1dnvtuw.1jbsu4e19zqwqgN@bay3-97.quincy.ziplink.net>:
> > A couple months ago, Ilya posted a comment to clp.misc that a non-greedy
> > regular expression was now more efficient than the equivalent
> > negated-character-class regular expression.
>
> > This is perl, version 5.005_02 built for MSWin32-x86-object
>
> I said *now*, not half-a-year ago.
>
So what version are your Benchmarks with??
If you were advising the original poster to use the "more efficient"
non-greedy matching based on a _development_ version of Perl, don't you
think you should have mentioned that?
> EnegC_n: 3 wallclock secs ( 2.35 usr + 0.00 sys = 2.35 CPU)
> EnegC_y: 2 wallclock secs ( 2.00 usr + 0.00 sys = 2.00 CPU)
> EnonG_n: 1 wallclock secs ( 1.72 usr + 0.00 sys = 1.72 CPU)
> EnonG_y: 2 wallclock secs ( 1.85 usr + 0.00 sys = 1.85 CPU)
I do see the effects of the optimization here. Non-greedy matching is
faster, without capturing parentheses.
> negC_n: 5 wallclock secs ( 3.85 usr + 0.00 sys = 3.85 CPU)
> negC_y: 3 wallclock secs ( 2.38 usr + 0.00 sys = 2.38 CPU)
> nonG_n: 4 wallclock secs ( 4.16 usr + 0.00 sys = 4.16 CPU)
> nonG_y: 3 wallclock secs ( 4.28 usr + 0.00 sys = 4.28 CPU)
But, as you can see, when capturing parens are used, the non-greedy
expression is still slower, particularly for a successful match.
> nonG_y => sub { $y =~ /"(.*?)"/s },
> nonG_n => sub { $n =~ /"(.*?)"/s },
> negC_y => sub { $y =~ /"([^\"]*)"/},
> negC_n => sub { $n =~ /"([^\"]*)"/},
> EnonG_y => sub { $y =~ /".*?"/s },
> EnonG_n => sub { $n =~ /".*?"/s },
> EnegC_y => sub { $y =~ /"[^\"]*"/},
> EnegC_n => sub { $n =~ /"[^\"]*"/},
>
> But you are right, the optimization might have worked with '()' too.
The regexes from the original thread:
/<a href="(.*?)"/
/<a href="([^"]*)"/
Your comment:
"It is already several days today since the moment the first expression
is *much* quickier than the second one..."
Both our Benchmarks show that this assertion was incorrect.
Sorry, but I'll have to continue my campaign against needless use of
non-greedy matching. :-)
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 28 Feb 1999 05:50:58 GMT
From: golfer@usa.net
Subject: Numeric Sort
Message-Id: <36d8d902.11330469@news.flash.net>
Was wondering if someone could help me. I have a tab delimited text
file with the following on each line (example):
Pete 56 23 88 99 23 2 8
Mike 99 32 45 12 11 8 90
What I want to do is sort these numerically from highest to lowest
written to a tab delimited file resulting in
Pete 99 88 56 etc
Mike 99 90 45 etc
Thanks for the help, I very new to perl and have read about sorting
but can't get a numeric sort to work.
------------------------------
Date: Sun, 28 Feb 1999 08:10:48 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Numeric Sort
Message-Id: <MPG.11430a61e27ff2989896af@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <u%5C2.4766$8N5.49494@typhoon-sf.pbi.net>, on Sat, 27 Feb
1999 23:11:49 -0800 coyote38@pacbell.net says...
> I enclosed a file that will do this type of sort for your specific problem.
> For documentation of the sort, consult your Perl reference book or
> your documentation that came with Perl in the document perlfunc.
...
> begin 666 test.pl
> M:68H(2 D05)'5ELP72D@(" C($EF('EO=2!D;VXG="!G970@=&AE(&9I;&5N
> M86UE(&%S(&%N(&%R9W5E;65N= T*>PT*"7!R:6YT(").86UE(&]F(&9I;&4@
> M>6]U('EO=2!W86YT('1O('!R;V-E<W,_7&XB.R @(",@<')O;7!T(&9O<B!P
...
Your advice about documentation is useful, your 'enclosed' file is not.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 28 Feb 1999 03:53:30 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Offtopic (Was: Re: custom dial script - simple if you know how - I don't)
Message-Id: <7baejq$4as$1@gellyfish.btinternet.com>
On 27 Feb 1999 23:18:46 -0000 Jonathan Stowe wrote:
>
> "You've got to prove you're mad to get out of here but if you want to
> get out of here you cant be mad" - thats catch 22 (wildly paraphrased as
> I cant find the book right now).
By Joseph Heller and a very good movie with for instance Larry Hagman,
Antony Perkins etc etc ..
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 01 Mar 1999 17:51:42 +0100
From: Heiko Marschall <hm@garmisch.net>
Subject: Re: open file problem
Message-Id: <36DAC59E.52DB7BB3@garmisch.net>
Oh - you did something really strange ... :-)
In that way you tried to connect via the http-protocol to the server -
that is not clearly defined and NOT a part of perl - for that you should
use a package with FTP-capabilities...
- Heiko -
> I want my perl script to open a data file on a seperate webserver...
> so I thought I could use something like
>
> (filehandle,">> http://www.somewhere.com/cgi-bin/datafile.txt");
>
> Is this legal perl as it doesn't seem to be working for me.....
>
> Regards
>
> Richard
>
> r.partridge@dewnters.com
--
-------------------------------------------------------------------
Dipl.Phys. Heiko B. Marschall - Geschdftsleitung
MARSCHALL ELECTRONICS GmbH & Co KG
hm@garmisch.net http://www.garmisch.net
Phone: +49 8821 943910-0 Kreuzackerstrasse 2
Fax: +49 8821 943910-99 D-82467 Garmisch-Partenkirchen
------------------------------
Date: Sat, 27 Feb 1999 19:40:59 -0800
From: "coyote38" <coyote38@pacbell.net>
Subject: Re: PC - UNIX text converter
Message-Id: <OV2C2.4663$8N5.45106@typhoon-sf.pbi.net>
Have you tried something like:
while($nextLine = <THEINFILE>)
{
chomp $nextLine;
print THEOUTFILE "$nextLine\n";
}
running on the OS you are converting to? Isn't \n translated to the proper
characters for the machine on which Perl is installed?
Another thing I tried that worked when converting from Mac
to Windows text (while running Perl on the Mac) was
$winReturn = pack("c2",10,13); # binary of return-newline
while($nextLine = <THEINFILE>)
{
chomp $nextLine;
print THEOUTFILE "$nextLine$winReturn";
}
Be sure to check what the numeric value of RETURN and LINEFEED are.
I may have mis-remembered them.
coyote38@pacbell.net
Fred O'Brian wrote in message ...
Am I missing something REALLY obvious here?
All I need is a tool to add/remove the carrage returns in
text files. Surely this must already exsist! Can anybody suggest
one? (I am using Redhat linux / Win95)
--
Fred O'Brian (remove NOSPAM from address)
------------------------------------------------------------------------
--
A stupid quote is like a drink from a muddy pool.
-The right confused Rev. Copernicus D1542
------------------------------------------------------------------------
-
------------------------------
Date: 28 Feb 1999 04:48:34 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl script to compare files
Message-Id: <7bahr2$rn5$3@client2.news.psi.net>
ben@kesslerconsulting.com (ben@kesslerconsulting.com) wrote on MMVI
September MCMXCIII in <URL:news:7b9h1i$rtl$1@nnrp1.dejanews.com>:
[] I'm looking to create a script that will compare the contents of two text
[] files (in this instance they are Cisco router configurations) and report any
[] differences in the second file relative to the first.
That's called diff.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5020
**************************************