[11107] in Perl-Users-Digest
Perl-Users Digest, Issue: 4706 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 21 01:05:52 1999
Date: Wed, 20 Jan 99 22:00:22 -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 Wed, 20 Jan 1999 Volume: 8 Number: 4706
Today's topics:
Re: $0 or @ARGV in a one-liner (??) (Abigail)
Re: arbitrary precision arithmetic (Abigail)
Re: Background Processes. (Abigail)
Re: chat2.pl and Solaris? (Randal L. Schwartz)
Re: chat2.pl and Solaris? <uri@home.sysarch.com>
Re: CHOWN problem (Tad McClellan)
Re: email a form (Abigail)
FAQ for this group? <AdvertisementsNotReadJustDeleted@RealAddressBelow.com>
Re: flock (Abigail)
Re: Help getting script going KernelKlink@webtv.net
Re: HELP: multiple write statements to one output fileh <rick.delaney@home.com>
Re: HELP: Netscape 4.5 doesn't like text/html header fr KernelKlink@webtv.net
Re: How to get IP address of a local machine under NT <mds-resource@mediaone.net>
Re: How to get IP address of a local machine under NT KernelKlink@webtv.net
Re: How to link image in Perl script ? <him@deva.net>
Re: Is there a way to create self contained perl execut (Alan Stewart)
memory leak (Perl-odbc-MSSQL) <ji1@home.com>
Re: Merging multiple files together........ (Tad McClellan)
Re: Newbie Perl CGIer needs fast help! Posting to URL (Abigail)
Re: Newbie string question, please help :) (Tad McClellan)
Re: Newbie string question, please help :) (Abigail)
Re: Newbie string question, please help :) (Abigail)
Newbie-Looking for Network Monitoring scripts <targa@cornhusker.net>
Re: Newbie-Looking for Network Monitoring scripts (Eric Hagen)
Re: Open File Detect (Alan Barclay)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Jan 1999 02:54:07 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: $0 or @ARGV in a one-liner (??)
Message-Id: <7864sf$ls8$2@client2.news.psi.net>
Martien Verbruggen (mgjv@comdyn.com.au) wrote on MCMLXVIII September
MCMXCIII in <URL:news:6Wtp2.58$Rq1.4085@nsw.nnrp.telstra.net>:
%%
%% Why is the -e flag passed on in @ARGV?
$ perl -wle 'print "@ARGV"' -- -foo
-foo
$
What -e?
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: 21 Jan 1999 03:02:34 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: arbitrary precision arithmetic
Message-Id: <7865ca$ls8$3@client2.news.psi.net>
perl -we 'print `echo "${\join "*" => 2 .. 23}" | bc -l`'
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: 21 Jan 1999 03:03:36 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Background Processes.
Message-Id: <7865e8$ls8$4@client2.news.psi.net>
Mike Watkins (mwatkins@promotion4free.com) wrote on MCMLXVIII September
MCMXCIII in <URL:news:#ElKr$KR#GA.261@ntdwwaaw.compuserve.com>:
^^
^^ I'll try to make this short and to the point. I'm trying to make a script
^^ which contains a feature to e-mail all members. Sometimes the script will
^^ probably have to send over 3000 personalized e-mails. I'm trying to figure
^^ out how I can show a "Currently Sending E-Mail" screen while the script is
^^ sending the e-mail in the background.
fork
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 20 Jan 1999 21:15:12 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: chat2.pl and Solaris?
Message-Id: <m1btjtnr4v.fsf@halfdome.holdit.com>
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:
Russ> You really want to use the Expect module from CPAN rather than chat2.pl,
Russ> which is likely to eventually be removed from the distribution.
chat2.pl *has* been removed from the distribution, I think starting in
5.003.
Russ> It's
Russ> pretty broken on a lot of platforms and is *really* old.
Yes, one of the two things I've written that ended up in the standard
distribution.
[extra bonus points if you can tell me what the other thing is!]
Russ> Expect and the
Russ> IO::* modules it uses are much more modern and much better implemented.
chat2.pl wasn't even *implemented*, as far as I was concerned. It was
alpha code, and I never even got around to a Beta. Larry put it into
4.019 without really consulting me (that I recall), probably because a
half dozen comp.lang.perl questions a month about using Perl to
control interactive processes were best answered with this weird code
as an interim solution.
Expect.pm is the right way to go now. I've toyed with building a
chat2.pl that starts with "use Expect" but I think there are more
important things for me to be working on.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 21 Jan 1999 00:59:28 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: chat2.pl and Solaris?
Message-Id: <x7ogntupxb.fsf@home.sysarch.com>
>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:
RLS> chat2.pl *has* been removed from the distribution, I think
RLS> starting in 5.003.
RLS> [extra bonus points if you can tell me what the other thing is!]
cd /usr/local/lib/perl5
grep Schwartz * */*
CPAN.pm: Author MERLYN (Randal L. Schwartz)
chat2.inter:## Randal L. Schwartz
chat2.inter:# from: Randal L. Schwartz
chat2.pl:# Randal L. Schwartz (was <merlyn@stonehenge.com>)
dumpvar.pl:# translate control chars to ^X - Randal Schwartz
lchat.pl:# which in turn was based on the Randal Schwartz version.
lchat.pl:# Randal L. Schwartz (was <merlyn@iwarp.intel.com>)
5.00502/CPAN.pm: Author MERLYN (Randal L. Schwartz)
5.00502/chat2.pl:# Randal L. Schwartz (was <merlyn@stonehenge.com>)
5.00502/dumpvar.pl:# translate control chars to ^X - Randal Schwartz
HTML/Base.pm:# Joel Rosi-Schwartz
pod/perlfaq2.pod: Authors: Larry Wall, Tom Christiansen, and Randal Schwartz
pod/perlfaq2.pod: Author: Randal Schwartz, with intro by Larry Wall
pod/perlfaq2.pod:(http://www.unixreview.com/). Randal Schwartz's Web Technique's
pod/perlfaq2.pod:and Randal Schwartz <perl-training-info@stonehenge.com>, plus their
pod/perlfaq2.pod:include Larry Wall, Tom Christiansen, and Randal Schwartz, whom you
pod/perlfaq4.pod:that's come to be known as the Schwartzian Transform:
pod/perlfunc.pod: # same thing using a Schwartzian Transform (no temps)
pod/perllol.pod:If you were into Schwartzian Transforms, you would prob
looks like chat2.pl is still in 5.005_02. you also claim to have written
CPAN.pm as well as dumpvar.pl.
do i get extra extra bonus for finding 2 more things you wrote in the
standard distribution? how 'bout you buying me a beer next time?
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Wed, 20 Jan 1999 23:09:30 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CHOWN problem
Message-Id: <aqc687.v2p.ln@magna.metronet.com>
Andy Biegel (andy@xsite.net) wrote:
: @delete="*.shtml";
: chown myusername, @delete;
: What am I doing wrong?
That is not how you take a filename glob.
chown myusername, <*.shtml>; # don't need a temp variable either
or
chown myusername, glob('*.shtml');
: What should I be doing differently?
You should be checking to see if the chown() succeeded:
chown myusername, glob('*.shtml') || die "could not change owner $!";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 1999 03:05:02 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: email a form
Message-Id: <7865gu$ls8$5@client2.news.psi.net>
Bill Sherry (bsherry@lucent.com) wrote on MCMLXVIII September MCMXCIII in
<URL:news:785l0j$36@nntpb.cb.lucent.com>:
``
`` I know how to create the form with HTML, I do not know how to write a script
`` that will extract the data from the form so that it can be emailed to
`` another person.
use CGI;
use Mail::Send;
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
------------------------------
Date: Wed, 20 Jan 1999 22:27:20 -0600
From: Steve <AdvertisementsNotReadJustDeleted@RealAddressBelow.com>
Subject: FAQ for this group?
Message-Id: <36A6ACA7.DDFBC2A9@geocities.com>
Is there a FAQ for this group?
Where can I get a copy?
Steve
someone34@geocities.com ICQ #: 15754141
The Vipassana Page:
http://rdz.acor.org/lists/vipassana
Home Page:
http://www.geocities.com/RainForest/Canopy/4774
----------------------------------------------------------
The current population of the Earth is 5.9 billion people.
If current birth and death rates continue, the Earth's
population will double in 40 years.
The Zero Population Growth Page:
http://www.zpg.org/popframe.htm
-----------------------------------------------------------
------------------------------
Date: 21 Jan 1999 03:16:48 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: flock
Message-Id: <786670$meu$1@client2.news.psi.net>
Graffiti (ramune@zarathustra.calstatela.edu) wrote on MCMLXVIII September
MCMXCIII in <URL:news:785eoh$obl$1@zarathustra.calstatela.edu>:
<>
<> Process A and B has a file open read-write. Process C has it open
<> read-only. Process A starts to write to the file. Process B tries
<> to write, but blocks. Process C tries to read and succeeds.
<> Process A finishes the write. Process B's write kicks in. Process
<> C is still reading.
Well, that's technically possible, but not very useful.
It's more like:
Process A has an exclusive lock on a file; because it needs to
modify the file. Processes B and C want to read the file, and
request a shared lock. Process D needs an exclusive lock, as it
has to modify the file as well. They all wait till A is done.
When A is done, B grabs the lock. Since it's shared, C gets its
lock too. D has to wait till B and C are ready.
Of course, this is very kludgy way because first of all, all process have
to act "nice" (locks aren't enforced; every application has to do all the
work themselves). But when they play nice, processes needing an exclusive
lock may never get it! Imagine that in the example above, before B and C
are finished, a process E comes along, wanting a shared lock as well. It
can go ahead, and D has to wait. Then F comes along, wanting a shared lock
and again, D has to wait....
It would have been much nicer if locking was done on the filesystem level,
and not the application level.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Wed, 20 Jan 1999 23:56:29 -0500 (EST)
From: KernelKlink@webtv.net
Subject: Re: Help getting script going
Message-Id: <2239-36A6B37D-103@newsd-103.iap.bryant.webtv.net>
Your server configuraton may require that you script have a .cgi
extension instead of a .pl extension.
------------------------------
Date: Thu, 21 Jan 1999 03:05:34 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: HELP: multiple write statements to one output filehandle
Message-Id: <36A69B52.21DB426D@home.com>
[posted & mailed]
anna@water.ca.gov wrote:
>
> What doesn't work:
> ------------------
> open(NEWR, ">$reportOut") || die "\nCan't open file: $!\n";
> ...
> $~='BASINS'; $^='topBASINS';
> ...
> select NEWR;
Oops, you've selected NEWR too late. If you want $~ and $^ to
correspond to the filehandle NEWR (and you do since that's the handle
associated with the file you're writing to), then you must select NEWR
first.
select NEWR;
$~='BASINS'; $^='topBASINS';
> write BASINS;
Alway, always run your programs with the -w switch. This would have
told you what you're doing wrong.
Write on closed filehandle
This should be
write NEWR;
because that's the handle associated with the file you're writing to.
Same goes for AREAS.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Thu, 21 Jan 1999 00:16:06 -0500 (EST)
From: KernelKlink@webtv.net
Subject: Re: HELP: Netscape 4.5 doesn't like text/html header from Perl script
Message-Id: <2241-36A6B816-22@newsd-103.iap.bryant.webtv.net>
Did you put a blank line after the Content Type line? Can we see the
source to trouble shoot it?
------------------------------
Date: Wed, 20 Jan 1999 21:34:16 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: How to get IP address of a local machine under NT
Message-Id: <36A6A038.7E817EEA@mediaone.net>
Gotcha!
On winDoze, unfortunately, they couldn't quite understand the cryptic
original; but, instead, called it: `ifconfig.'
Bet that'll get you to install winDoze }:-^
Abigail wrote:
>
> KernelKlink@webtv.net (KernelKlink@webtv.net) wrote on MCMLXVII September
> MCMXCIII in <URL:news:14993-36A4F973-1@newsd-101.iap.bryant.webtv.net>:
> ;;
> ;; ipconfig
>
> That's ifconfig. It gives me 127.0.0.1.
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Wed, 20 Jan 1999 23:23:53 -0500 (EST)
From: KernelKlink@webtv.net
Subject: Re: How to get IP address of a local machine under NT
Message-Id: <2239-36A6ABD9-97@newsd-103.iap.bryant.webtv.net>
It has nothing to do with Perl buuut, if you type ipconfig while online
it should give you the IP assigned to your machine at sign-on (uless you
have a static IP), when you're off-line you should get 127.0.0.1
------------------------------
Date: Thu, 21 Jan 1999 12:29:41 +0800
From: Chris Kwan <him@deva.net>
Subject: Re: How to link image in Perl script ?
Message-Id: <36A6AD35.E0241986@deva.net>
> print "Content-type: text/html\n\n";
> print "<CENTER><IMG SRC="mainlogo.gif" HEIGHT=54 WIDTH=577></CENTER>";
quick and dirty:- take out the double quotes.
i.e
print "<CENTER><IMG SRC=mainlogo.gif HEIGHT=54 WIDTH=577></CENTER>";
> The image already saved in my cgi-bin directory.
it's not a very good idea to put your images under your cgi-bin.
i suggest that u should put them elsewhere.
--
Chris KWAN
Consultant
Wild Technologies Limited
------------------------------
Date: Thu, 21 Jan 1999 04:04:39 GMT
From: astewart@spawar.navy.mil (Alan Stewart)
Subject: Re: Is there a way to create self contained perl executable?
Message-Id: <36a6a0ce.771782634@news.pwy1.sdca.home.com>
On 20 Jan 1999 07:07:17 -0700, Tom Christiansen <tchrist@mox.perl.com>
wrote:
[snip]
>Let's suppose that your script is 5k and the perl installation is
>two megatabytes. If you give them both together, it costs 2.005
>megabyte.s If you give them three such scripts, it's now going to
>cost 6.015 megabytes. Do you see where this is going? It's a bad idea.
>Just give them the script. If they want Perl, they know where to find it.
I have just one Perl application to run on Navy ships (no other Perl
needed on those machines). I wrote the application in Perl, in part,
to save you, the taxpayer, some money because it didn't take me as
long to build. The ship's crew CAN'T just get Perl, don't know where
or how, and don't need it for anything else. In my situation, you
would have me fly to every ship (maybe 200) worldwide, install Perl on
every host (maybe 100 on a ship), and hand them the source. Not very
good for the taxpayer, much less me. The cost of disk space is
negligible.
It is true, in my own office, I install Perl on every machine I get my
hands on, and I press my source scripts into the hands of everyone I
see, but it is not always appropriate.
On the other hand, if some Perl organization wants to pay my per diem
for the next 6 months, I leave now.
[snip]
>PS: The cited perl2exe thingie ranges from remarkably stupid at its
> best to a dangerous lie at its worst, depending on how it is
> presented. Forget it.
I use the perl2exe thingie with success, not to do the infernal code
hiding (in fact, all my work is available under the freedom of
information act), but for it's "one lump" packaging. It has it's
limitations, and I have had to work around a couple, but I have found
it useful at best and not a lie, since it does what the author says it
does (as opposed to what someone else might assume it does for them).
He doesn't claim it runs faster, he says you don't need the source
code along with the .exe, he does NOT say the source can't be decoded
from the .exe (I know it can), he says it runs without installing
Perl. Good enough for me.
>--
>pos += screamnext[pos] /* does this goof up anywhere? */
> --Larry Wall, from util.c in the v5.0 perl distribution
------------------------------
Date: Thu, 21 Jan 1999 05:32:01 GMT
From: "jim" <ji1@home.com>
Subject: memory leak (Perl-odbc-MSSQL)
Message-Id: <lZyp2.880$qW5.607@news.rdc1.sfba.home.com>
Hi,
We are running a web site using NT 4.0 with service pack 4 and mssql 6.5.
We have some perl scripts read and update the database. We are running
into some memory leak problems. If we leave the system running for a couple
of days, the IIS server will grabs all the memory in the system and
eventually
make the system useless. We suspect the problem is in the perl or odbc
since we also use IDC to query the database. If we turn off perl scripts,
it is not much a problem.
Has anyone out there experienced the same probem? Is this a bug in
perl, odbc, or IIS? Any pointer will be highly appreciated.
Jim
------------------------------
Date: Wed, 20 Jan 1999 22:53:02 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Merging multiple files together........
Message-Id: <erb687.v2p.ln@magna.metronet.com>
Dee (darrick@2unreal.com) wrote:
: Sorry for not including more informaion with my previous post. The data
: contained in the files look like this:
: 12-01-99 10:02:23 John Doe Portland Or 97211
: The data is separated by just a single space. The fields do not have a
: character limit. I would like to merge the information from multiple txt
: files into just one txt file. I would like to sort the entries by date and
: then time.
Here you go:
-------------------------------
#!/usr/bin/perl -w
use strict;
my(@stuff) = <DATA>;
@stuff =
map { $_->[0] }
sort {
$a->[3] <=> $b->[3] or # year
$a->[1] <=> $b->[1] or # month
$a->[2] <=> $b->[2] or # day
$a->[4] <=> $b->[4] or # hour
$a->[5] <=> $b->[5] or # minute
$a->[6] <=> $b->[6] # second
}
map { [$_, /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/] }
# or map { [$_, split /[-: ]/, $_, 7] }
@stuff;
foreach (@stuff) {
print;
}
__DATA__
11-13-99 10:02:23 John Doe Portland Or 97211
11-01-99 10:02:23 John Doe Portland Or 97211
12-01-99 11:10:23 John Doe Portland Or 97211
12-01-99 11:02:23 John Doe Portland Or 97211
12-01-99 09:02:23 John Doe Portland Or 97211
12-01-99 10:02:23 John Doe Portland Or 97211
12-01-99 10:02:01 John Doe Portland Or 97211
-------------------------------
That shows how to use the Schwartzian Transform to sort them
once you have collected them all into the @stuff array.
To collect the records from the various files, you could do
something like:
@stuff = <>; # grab all the lines from all the files whose
# names were given as arguments
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 1999 02:50:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Newbie Perl CGIer needs fast help! Posting to URL
Message-Id: <7864md$ls8$1@client2.news.psi.net>
(//trxby) (ttxyxexr@airxmail.net) wrote on MCMLXVIII September MCMXCIII
in <URL:news:AA368C7E8B2EF9A1.72EF6A6D9BADAC56.0F8C2271CC0C7122@library-proxy.airnews.net>:
() I am a programmer Abigail.
Then you know how to RTFM.
() I'm just not that experienced with Perl using these functions.
I told you what to use. Now go and RTFM.
() All I am asking is to be pointed to some specific functions. I'm not
() asking someone to do the programming for me. The client has had four
() months to get this ready. I prodded for two months until they told me
() to leave it alone. Now they want it up in three days and I don't have
() a whole lot of time to study up, find someone else AND get rid of my
() other clients at the same time.
I still say you should hire a programmer. Not any random programmer.
But one who knows the material and can do the task in 3 days.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|8;
.qq;8768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F;
.qq;76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V
/=$^U}while$^V!=$^W'
------------------------------
Date: Wed, 20 Jan 1999 20:48:28 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie string question, please help :)
Message-Id: <sh4687.feo.ln@magna.metronet.com>
Ban Spam Now (no_spam@no_spam.com) wrote:
: How do I loop through the string character by character and perform an
: operation based on the current character?
: how to do it in Perl?
foreach $char ( split //, $string) {
doM() if $char eq 'M';
doE() if $char eq 'E';
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 1999 03:30:09 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Newbie string question, please help :)
Message-Id: <786701$meu$2@client2.news.psi.net>
Ban Spam Now (no_spam@no_spam.com) wrote on MCMLXVIII September MCMXCIII
in <URL:news:785i0u$odp@sjx-ixn6.ix.netcom.com>:
::
:: How do I loop through the string character by character and perform an
:: operation based on the current character?
$1 eq 'M' ? something () : something_else () while $string =~ /([ME])/g;
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
------------------------------
Date: 21 Jan 1999 03:39:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Newbie string question, please help :)
Message-Id: <7867hc$meu$3@client2.news.psi.net>
Daniel Grisinger (dgris@moiraine.dimensional.com) wrote on MCMLXVIII
September MCMXCIII in <URL:news:m37luhy2p3.fsf@moiraine.dimensional.com>:
^^ Far better is to load up a dispatch table containing input keys
^^ and associated functions. Like so-
^^
^^ my %dispatch_table = ( a => \&do_something_with_a,
^^ b => \&do_something_with_b,
^^ ...
^^ '*' => \&do_something_with_star );
^^
^^ for (split //, $input) {
^^ if (exists ($dispatch_table{$_}) {
^^ &{$dispatch_table{$_}}(@args);
^^ next;
^^ }
while ($string =~ /(.)/g) {
no strict;
&{"do_something_with_$1"} (@args) if defined &{"do_something_with_$1"};
}
^^ my %dispatch_table = ( '^\s*#(.+)$' => \&capture_comment,
^^ '^=([^\s]+)\s*$' => \&capture_pod,);
^^
^^
^^ for (keys %dispatch_table) {
^^ if ($input =~ /$_/) {
^^ &{$dispatch_table{$_}}(@args);
^^ last;
^^ }
^^ }
^^
^^ This could probably be better accomplished today using qr// and
^^ deeper data structures, but that just an optimization of what is
^^ a very powerful technique.
But that does the things in order of keys(), *not* in the order how
things appear in the string.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|8;
.qq;8768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F;
.qq;76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V
/=$^U}while$^V!=$^W'
------------------------------
Date: Wed, 20 Jan 1999 21:33:26 -0600
From: "Michael J. Bahr" <targa@cornhusker.net>
Subject: Newbie-Looking for Network Monitoring scripts
Message-Id: <36A6A005.B48E1D3F@cornhusker.net>
Hello all,
Im trying to find some scripts or pointers for help to do the following:
I need to produce a network map in html format, indicating which of my
nodes are up and which are down. Im using active perl on a Win32
platform. I found an article
(http://www.webdeveloper.com/categories/management/management_network_mapping.html)
on doing this using fping and gd.pm but I couldn't find a compatible
win32 based ping program - (or rather dont know how to implement it.)
Basically I create a .gif image of the network and a text file with the
coordinates and IP of each node on the gif. The ping program needs to
ping the contents of the text file and return all non-responding nodes.
It should then look up the coordinates of the non-responding nodes and
fill those areas of the gif with the color red (using gd.pm) It should
the print it to html.
Anyone have any ideas on how to do this or perhaps another solution?
TIA
Michael Bahr
------------------------------
Date: 21 Jan 1999 04:17:57 GMT
From: ehagen@Hawaii.Edu (Eric Hagen)
Subject: Re: Newbie-Looking for Network Monitoring scripts
Message-Id: <7869pl$l1i@news.Hawaii.Edu>
I could recomend looking at MRTG.
http://www.ee.ethz.ch/~slist/mrtg
I have also seen a few other perl programs that do similar things as you
describe, however I do not have any bookmarks for them, nor can I remember
the names of them. Sorry.
You could also look into scotty and tkined, there are some plugins etc
that can do what your looking for.
Eric
Michael J. Bahr (targa@cornhusker.net) wrote:
: Hello all,
: Im trying to find some scripts or pointers for help to do the following:
: I need to produce a network map in html format, indicating which of my
: nodes are up and which are down. Im using active perl on a Win32
: platform. I found an article
: (http://www.webdeveloper.com/categories/management/management_network_mapping.html)
: on doing this using fping and gd.pm but I couldn't find a compatible
: win32 based ping program - (or rather dont know how to implement it.)
: Basically I create a .gif image of the network and a text file with the
: coordinates and IP of each node on the gif. The ping program needs to
: ping the contents of the text file and return all non-responding nodes.
: It should then look up the coordinates of the non-responding nodes and
: fill those areas of the gif with the color red (using gd.pm) It should
: the print it to html.
: Anyone have any ideas on how to do this or perhaps another solution?
: TIA
: Michael Bahr
--
Eric Hagen "Sometimes we get lost in the darkness,
ehagen@Hawaii.Edu the dreamers learn to steer by the stars..."
"You fight for something because it is good.
Not because it stands to succeed."
------------------------------
Date: 21 Jan 1999 04:41:10 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Open File Detect
Message-Id: <916893666.579699@elaine.drink.com>
In article <785h55$a$1@news0-alterdial.uu.net>,
Greg Ward <gward@cnri.reston.va.us> wrote:
>There must be some way under Unix to find out if a file is open; after
>all, the 'fuser' command does it. But I don't know what it is, and I
>don't know if it's easily accessible through Perl. If you're *really*
Under Linux, it's relativly easy.
Each process has a fd directory, /proc/{pid}/fd . In this directory you'll
find a number of symlinks to files,
lr-x------ 1 gorilla users 64 Jan 20 23:38 0 -> [0301]:4274
l-wx------ 1 gorilla users 64 Jan 20 23:38 1 -> [0301]:4275
l-wx------ 1 gorilla users 64 Jan 20 23:38 2 -> [0301]:4275
lrwx------ 1 gorilla users 64 Jan 20 23:38 3 -> [0000]:2476015
so this process has the filesystem on 3,1 inode 4274 open as stdin, and
inode 4275 open as stdout.
For other UnixlikeOS's, it much harder. Generally you've got to look
into the kernel, which means root permissions and knowning the kernel
data structures.
------------------------------
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 4706
**************************************