[17515] in Perl-Users-Digest
Perl-Users Digest, Issue: 4935 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 20 18:05:53 2000
Date: Mon, 20 Nov 2000 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)
Message-Id: <974761511-v9-i4935@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 20 Nov 2000 Volume: 9 Number: 4935
Today's topics:
[Perl - file IO] editing & displaying *.CSV files <hs0001@cosworth.de>
Re: Batch inserting into Oracle with Perl davewang168@my-deja.com
Re: Batch inserting into Oracle with Perl rereidy@my-deja.com
Re: Beginners Blues II <bart.lateur@skynet.be>
Re: Beginners Blues II <johngros@Spam.bigpond.net.au>
Re: Beginners Blues II <johngros@Spam.bigpond.net.au>
Re: Check if e-mail bounced with Mail::Bulkmail <elijah@workspot.net>
Code trash (Donkey_perlM)
Re: Command Line Perl (Martien Verbruggen)
desperate pls help me! <mlambert@concentric.net>
Re: desperate pls help me! <szetlan@uu.net>
fetch <todd@mrnoitall.com>
Re: fetch (Greg Bacon)
Re: File::Find's results to an array <bart.lateur@skynet.be>
Re: looking for PERL GUI debugger for UNIX <cuda71@delanet.com>
Re: looking for PERL GUI debugger for UNIX (Martien Verbruggen)
making a daemon server (Fran Turgeon Bridges)
Re: making a daemon server (Greg Bacon)
Pattern Matching Problem <sleeping.rough@sallyarmy.org.uk>
Re: Pattern Matching Problem (Greg Bacon)
Re: Perl spider performance <dwilgaREMOVE@mtholyoke.edu>
perlmenu: install question n.paulsen@gmx.net
Re: Question about Buttons and Subroutines pape_98@my-deja.com
Re: question about reusing a variable from a regex (Charles DeRykus)
Re: rearranging a text file <vigne@nhamp.net>
Re: rearranging a text file <bart.lateur@skynet.be>
Re: starting a perl script as an NT service rereidy@my-deja.com
Time of Scripts <meNOSPAM@toao.net>
Re: Time of Scripts (Martien Verbruggen)
Re: Time of Scripts <jeffp@crusoe.net>
using exec cgi in a perl program u0107@cheerful.com
Weird question: has anyone used Perl to parse the Shout dack@visi.com
writing system error messages to a logfile... akothek@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 20 Nov 2000 23:25:40 +0100
From: "Holger" <hs0001@cosworth.de>
Subject: [Perl - file IO] editing & displaying *.CSV files
Message-Id: <mLFqwC0UAHA.211@fnews1.vi-internet.de>
Hello friends of Perl,
did anyone out there have some experience with editing and displaying *.CSV
files? I plan to on the one hand search an *.CSV file (via a form) and on
the other add new datasets to it using a fix dataset structure. Also it
should be possible to download the whole file via a downloadlink to your
local machine and delete specific datasets.
Did anyone of you had written something like that or could tell me if
there's something in the web doing that fine?
I would be very pleased, if you can provide me with some info regarding that
topic. Please mail me at hs0001@cosworth.de, if you could help.
Bye,
Holger, Webmaster of Cosworth.de
------------------------------
Date: Mon, 20 Nov 2000 20:33:03 GMT
From: davewang168@my-deja.com
Subject: Re: Batch inserting into Oracle with Perl
Message-Id: <8vc1pv$uh1$1@nnrp1.deja.com>
Phil -
So what I've been doing is reading in a file, parsing the contents of
each line and inserting the IP address and data into Oracle. I think
it's Oracle that's slowing everything down. I could use SQL Loader, but
if I don't have to, I would prefer not to.
Thanks in advance for your help!
So here's what I've been doing..
==========================================================
[..connect to Oracle database]
while (defined($file = readdir(CAMDIR))) {
open(FILENAME, "/bin/gzip -dc /export/prodlogs/$file |")
while ($line = <FILENAME>) {
[..parse line into field such as $IP, $date, etc]
my($sth, $p1, $p2, $tmp, $stmt);
$stmt = qq{insert into IP (IP, thedate) values ('$ip', '$date')};
$sth = $dbh->prepare($stmt);
$sth->execute;
}
}
=====================================================================
In article <8v0p9i$ev4@fidoii.CC.Lehigh.EDU>,
"Phil R Lawrence" <prlawrence@lehigh.edu> wrote:
> Not sure what a "batch insert" is... please post what you find out.
> Meanwhile I might be able to help you speed up your current attempt.
Please
> post the code so we can all see what you're doing...
>
> Phil R Lawrence
>
> <davewang168@my-deja.com> wrote in message
> news:8uv6u1$3ks$1@nnrp1.deja.com...
> > Hi,
> >
> > I am building a simple web log parsing program that will insert the
IP
> > addresses of my users into an Oracle 8i database.
> >
> > I've tried the obvious: "insert into IPtable (IP) values ($IP)"
> >
> > .. and it takes forever to go through a 10mb log file.
> >
> > I've heard there's a faster way to do this using batch inserts. Has
> > anyone had experience doing something similar? If so, I'd greatly
> > appreciate any tips.
> >
> > Thanks!
> > David
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 20 Nov 2000 21:08:15 GMT
From: rereidy@my-deja.com
Subject: Re: Batch inserting into Oracle with Perl
Message-Id: <8vc3ro$do$1@nnrp1.deja.com>
David,
A couple of things:
1. You should only prepare the statement once. See the DBI doc on
bind_param().
2. You should look at using direct inserts or SQL*Loader if this does
not help. Your DBA and the docs should be able to help you out with
these.
Good luck.
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
In article <8vc1pv$uh1$1@nnrp1.deja.com>,
davewang168@my-deja.com wrote:
> Phil -
>
> So what I've been doing is reading in a file, parsing the contents of
> each line and inserting the IP address and data into Oracle. I think
> it's Oracle that's slowing everything down. I could use SQL Loader,
but
> if I don't have to, I would prefer not to.
>
> Thanks in advance for your help!
>
> So here's what I've been doing..
> ==========================================================
> [..connect to Oracle database]
>
> while (defined($file = readdir(CAMDIR))) {
> open(FILENAME, "/bin/gzip -dc /export/prodlogs/$file |")
> while ($line = <FILENAME>) {
>
> [..parse line into field such as $IP, $date, etc]
>
> my($sth, $p1, $p2, $tmp, $stmt);
> $stmt = qq{insert into IP (IP, thedate) values ('$ip', '$date')};
> $sth = $dbh->prepare($stmt);
> $sth->execute;
> }
> }
> =====================================================================
>
> In article <8v0p9i$ev4@fidoii.CC.Lehigh.EDU>,
> "Phil R Lawrence" <prlawrence@lehigh.edu> wrote:
> > Not sure what a "batch insert" is... please post what you find out.
> > Meanwhile I might be able to help you speed up your current attempt.
> Please
> > post the code so we can all see what you're doing...
> >
> > Phil R Lawrence
> >
> > <davewang168@my-deja.com> wrote in message
> > news:8uv6u1$3ks$1@nnrp1.deja.com...
> > > Hi,
> > >
> > > I am building a simple web log parsing program that will insert
the
> IP
> > > addresses of my users into an Oracle 8i database.
> > >
> > > I've tried the obvious: "insert into IPtable (IP) values ($IP)"
> > >
> > > .. and it takes forever to go through a 10mb log file.
> > >
> > > I've heard there's a faster way to do this using batch inserts.
Has
> > > anyone had experience doing something similar? If so, I'd greatly
> > > appreciate any tips.
> > >
> > > Thanks!
> > > David
> > >
> > >
> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.
> >
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 20 Nov 2000 19:25:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Beginners Blues II
Message-Id: <iiui1t83l0onl43a14emb6ppc3vbr30pru@4ax.com>
John Boy Walton wrote:
>@name = split (/@/,$name); # splits the email to pre @ and post @
@name = split /\@/,$name;
>$name = @name(0) + "\\\@" + @name(1); # should add the pre @ (johngros) with
>\@ and with post @ (bigpond.net.au).
$name = $name[0] . "\\\@" . $name[1];
or:
$name = join "\\\@", @name;
or:
$name = "$name[0]\\\@$name[1]";
--
Bart.
------------------------------
Date: Mon, 20 Nov 2000 22:09:57 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Beginners Blues II
Message-Id: <VihS5.14909$tU2.126485@news-server.bigpond.net.au>
Actually a mate used print "$pwd+/n"; and it worked mind you I tried it and
could not get it to work.
------------------------------
Date: Mon, 20 Nov 2000 22:26:56 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Beginners Blues II
Message-Id: <QyhS5.14915$tU2.126716@news-server.bigpond.net.au>
The @ did need to be escaped it did not show when I tried it without
escaping the @. But here is the thing it worked. I don't need to cut up the
string to insert the escape character for the @. I had to when I assigned a
value to the string. <stdin> looks after it for me.
------------------------------
Date: 20 Nov 2000 21:28:37 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Check if e-mail bounced with Mail::Bulkmail
Message-Id: <eli$0011201616@qz.little-neck.ny.us>
In comp.lang.perl.misc, Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> Matthijs van den Bos <mvdbos@integral.nl> wrote:
> > I wrote a mailinglist server using Mail::Bulkmail.
> > Everything works fine, except the checking of addresses that bounced.
> > As far as I could see, this module doesn't provide functionality for
> > this.
> Use one of the mail client oriented modules. Check your mailbox. Try to
> find all messages that are related to bounces. Try to parse them to
> extract what the email address was that the message was originally sent
> to.
>
> You'll be surprised how hard it is to get a decent success rate.
The trick to doing it very successfully (and a trick I am fairly
sure Mail::Bulkmail doesn't use since it is an anti-optimization)
is to send each message out with a unique envelope 'From' address.
The 'From' address in the headers does not need to change, just
the one used in the SMTP session.
By spec all bounce messages go to the envelope address, while
normal mailreaders prefer the header 'From' address.
It is an anti-optimization in that it prevents the program from
sending the message once when there are multiple recipients at
one host. Instead each message must be sent seperately.
If you really care about catching bounces, rewrite your script
to use a different mailer so you can send each message with
a different envelope. There are mailing list programs that do
this, but I don't know if they are written in perl.
Elijah
------
not sure that all software follows the RFCs on this
------------------------------
Date: Mon, 20 Nov 2000 20:59:30 GMT
From: ghard296@jaminnet.com (Donkey_perlM)
Subject: Code trash
Message-Id: <Xns8FF2AB87502188@24.128.8.202>
I've been trying to get this trash load of code i wrote down to fast, CPU
friendly code. Unfortunately, I have failed miserably in my attempt.
sub OpenThread {
my $ThreadFile = shift;
@forumfacts = &GetForumRecord($number);
$ThisPassword = &decodeURL($forumfacts[7]);
$ExactPath = ($forumfacts[6] eq 'private') ? "Forum$number/private-
$ThisPassword" : "Forum$number";
if(($ThreadFile =~ /^\d{6}\.(cgi|ubb)$/)||($ThreadFile =~ /^\d{6}-\d{6}-\d
{6}-\d{6}\.(n|m|msg|nmsg)$/)) {
open(MESSAGE, "$ForumsPath/$ExactPath/$ThreadFile")or die "Bad file: $!";
my @mess = sort <MESSAGE>;
close (MESSAGE)or die "Bad file: $!";
return(@mess);
} else {
#&PostHackDetails;
#die(&StandardHTML("<p>NOTICE! This request and your user data were logged as
a hack attempt. Authorities will be alerted if you persist.</p><p>If you
believe this to be an error please contact $BBEmail to say there may be
corrupt data files in Forum $number. ($ThreadFile)</p>"));
}
}
and, this one works fast, but it has errors and needs improving.
sub GetUserNumber {
my $GetNameClean = quotemeta(UNHTMLIFY(shift));
return $ProfileNumber{$GetNameClean} if ($ProfileNumber
{$GetNameClean});
open (MEMFILE, "$MembersPath/memberslist.cgi") or die "Can't open
file: $!";
while (<MEMFILE>) {
next unless /^$GetNameClean\|\!\!\|/;
chomp;
($MatchName, $ProfileNumber) = split /\|\!\!\|/;
last;
}
close (MEMFILE) or die "Can't close file: $!";
$ProfileNumber{$GetNameClean} = $ProfileNumber;
return $ProfileNumber;
}
If any of you find any way of doing this, e-mail me the finished sub, OR,
give me small code help.
------------------------------
Date: Mon, 20 Nov 2000 22:01:34 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Command Line Perl
Message-Id: <slrn91j7ou.r2.mgjv@verbruggen.comdyn.com.au>
On Mon, 20 Nov 2000 16:07:11 GMT,
Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
> perl -le 'print -A for @ARGV' *.*
> anybody with better scores?
Perl does globbing internally:
perl -le 'print -A for <*.*>'
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: 20 Nov 2000 20:23:24 GMT
From: "M Lambert" <mlambert@concentric.net>
Subject: desperate pls help me!
Message-Id: <8vc17s$sgt@dispatch.concentric.net>
Im trying to write a cgi that will allow users to run a reporting tool and
have the report emailed to them... the problem is the reports can take up to
3 hours to generate. How do I background a process in Perl that will allow
users to visit a cgi and leave while the pro finoishes up without them...
ive exhausted all resources and am serioulsy considering opening a telent
socket to THE SAME mahcine via the Perl CGI in order to "nohup runinit &".
Any ideas???
system("$path/$to/$prog &"); DOES NOT work... like i said this process
takes
a long time to complete (3 hours)... it times out with the browser and I
cant get it to stay alive!!!!! im very very desperate... anyone?
------------------------------
Date: Mon, 20 Nov 2000 17:01:18 -0500
From: "Scott Zetlan" <szetlan@uu.net>
Subject: Re: desperate pls help me!
Message-Id: <3a199ec6$0$2496@wodc7nh0.news.uu.net>
Try using fork() instead of system() -- then the parent/child processes can
run asynchronously.
M Lambert wrote in message <8vc17s$sgt@dispatch.concentric.net>...
<snip>
>3 hours to generate. How do I background a process in Perl that will allow
>users to visit a cgi and leave while the pro finoishes up without them...
<snip>
>system("$path/$to/$prog &"); DOES NOT work... like i said this process
>
------------------------------
Date: Mon, 20 Nov 2000 15:37:09 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: fetch
Message-Id: <3A1987DA.D813A671@mrnoitall.com>
Dear Friendly People (only),
Any one know what code would be used to execute a second script while
executing the first script?
ie:
fetch "Location: http://my.com/script?login=bill&password=1234";
------------------------------
Date: Mon, 20 Nov 2000 22:39:24 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: fetch
Message-Id: <t1ja0s7nm1f1fb@corp.supernews.com>
In article <3A1987DA.D813A671@mrnoitall.com>,
Todd Anderson <todd@mrnoitall.com> wrote:
: Any one know what code would be used to execute a second script while
: executing the first script?
fork()
HTH,
Greg
--
In an intellectually equal society, who will be the busboys?
-- Lenny Bruce
------------------------------
Date: Mon, 20 Nov 2000 19:18:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File::Find's results to an array
Message-Id: <4tti1ts6lig4cobvp1cn78en0i6f29l469@4ax.com>
dionysus wrote:
>>my @files;
>
>doesn't my mean that that instance of
>@files is different to any instance of @files referred to anywhere
>outside of the sub wanted?
>
>>sub wanted { push @files, $File::Find::name }
Yes, but only if the "my" statement was inside the sub. It is not. It's
outside the sub, so it has a wider scope. If there is another enclosing
block; then the scope is that block. If there isn't, the scope is the
file. Other files, such as those included with require(), do() or use(),
cannot see it.
{
my $x;
sub set {
$x = shift;
}
sub get {
$x;
}
}
$x = 123;
set(456);
print "\$x is $x\n";
print "but that other \$x is ". get(). "\n";
-->
$x is 123
but that other $x is 456
--
Bart.
------------------------------
Date: Mon, 20 Nov 2000 21:25:16 GMT
From: NEWIMAGE <cuda71@delanet.com>
Subject: Re: looking for PERL GUI debugger for UNIX
Message-Id: <3A199755.5113E46F@delanet.com>
I am confused on one thing? You said, "they seem to have an aversion
to open source" , "they" being management. What the hell do they think
Perl is???? I'm sorry for the outburst of emotion but it seems kind of
stupid! I am sure you are probably sitting back saying, I know, I know,
I know, but that doesn't help solve my problem.
We went down this road not to long ago with the company I work for. In
the end we spent more money than I care to think about for very little
gain. As a general rule I have found technical people accomplish more
given a basic tool set. Let programmers be programmers and let the
users be users. Fancy utilities chock away functionality. A good
programmer is only limited by utilities that paint pretty pictures to
tell them the same thing the stock utilities would have.
Encourage your supervisors to consider open source, especially since
they seem to already be using "Perl" which is of course open source.
Buy them a copy of the "The Cathedral and the Bazaar", Eric S. Raymond
for Christmas and maybe suggest the go to the Linux Conference coming up
in New York. We have found nothing but good things on our road to an
open source shop, not to mention the amount of money we have saved our
company.
Good Luck, your going to need it with management like that!
Mike....
------------------------------
Date: Mon, 20 Nov 2000 21:50:30 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: looking for PERL GUI debugger for UNIX
Message-Id: <slrn91j746.r2.mgjv@verbruggen.comdyn.com.au>
On Mon, 20 Nov 2000 15:30:06 -0000,
Shallowen <shallow@mail.com> wrote:
> Martien Verbruggen wrote:
>>
>>
>> On Mon, 20 Nov 2000 11:30:09 -0000,
>> Shallowen <shallow@mail.com> wrote:
>> > Does anyone know of a stable, well-featured commercial debugger for UNIX
>> > (Solaris)?
>>
>> perl has a debugger, albeit one withouth mouse support. Read the
>> perldebug documentation. If you want a point and click interface, DDD
>> has some perl support: last time I bothered to check it was fairly
>> primitive and slightly off.
>
> It's not so much the ability to use the mouse, but the ability to have
> charts, and to see variables in realtime etc.
Ok. In that case you may want to give DDD a chance. Like I said, last
time I bothered to check its support for Perl wasn't very mature, or I
didn't do the right things. It's been a while, though, so maybe it's
become better. DDD works very well together with gdb for C projects.
Someone else suggested a Tk wrapper around the Perl debugger (?).
> Or so I am given to understand.
> I have been tasked to find this thing, not to justify it (I leave that to
> people far more senior then me.)
*grumble*
People, no matter how senior, don't always know what's best.
>> > Budget is reasonably large, but it should be closed-source please
>> > (so I can persuade management to sign it off; they seem to have
>> > an aversion to open source, even on things which have no contact
>> > with the outside world.)
>>
>> Euhmmmm... If they have a problem withOpen Source, what do they think
>> perl is?
>
> Yes, I know... this is something I've pointed out. Some other departments
> use Linux etc., but we get all the commercial CAD etc. etc., and it is
Isn't this partial blindness interesting?
>> I don't think ActiveState's stuff works anywhere but under windows, but
>> if your budget is large enough, maybe you could get them to port it to
>> Solaris.
>
> Hmm, not sure I could get _that_ signed off :)
Heh. I'm not sure I'd want you to :)
Martien
--
Martien Verbruggen |
Interactive Media Division | This matter is best disposed of from
Commercial Dynamics Pty. Ltd. | a great height, over water.
NSW, Australia |
------------------------------
Date: 20 Nov 2000 21:20:00 GMT
From: bridges@mailer.fsu.edu (Fran Turgeon Bridges)
Subject: making a daemon server
Message-Id: <8vc4i0$n70$1@news.fsu.edu>
I have a process that I wish to make a daemon. Using the "Perl Cookbook"
I have created the job to execute a system call every 120 seconds. When I
run it stand alone it runs fine. When I run it as a daemon it does not
run my system call.
I have included the job below. Do any errors leap out to anyone?
Thanks
-Fran Bridges
#!/usr/local/bin/perl
use POSIX;
chroot ("/var/daemon") or
die "Couldn't chroot to /var/daemon: $!";
$pid = fork;
exit if $pid;
die "Coulen't fork: $!" unless defined($pid);
POSIX::setsid()
or die "Cannot start a new session: $!";
$time_to_die = 0;
until ($time_to_die) {
$status = system("/mypath/to/mycommand");
sleep(60);
}
sub signal_handler {
$time_to_die = 1;
}
--
Fran Turgeon Bridges e-mail: bridges@acns.fsu.edu
------------------------------
Date: Mon, 20 Nov 2000 22:25:58 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: making a daemon server
Message-Id: <t1j97mph33v795@corp.supernews.com>
In article <8vc4i0$n70$1@news.fsu.edu>,
Fran Turgeon Bridges <bridges@mailer.fsu.edu> wrote:
: I have a process that I wish to make a daemon. Using the "Perl Cookbook"
: I have created the job to execute a system call every 120 seconds.
Perl's system() operator runs shell commands. System calls are traps
into the kernel. There's a huge difference.
: When I run it stand alone it runs fine. When I run it as a daemon it
: does not run my system call.
Looking at your code, I don't see you installing a signal handler or
calling alarm(). Did you post a copy of your code or a paraphrased
version? Paraphrased versions are almost always unhelpful.
Greg
--
Beware of the above code; I have only proved it correct, not tried it.
-- Knuth
------------------------------
Date: Mon, 20 Nov 2000 20:46:25 -0000
From: "Phil Latio" <sleeping.rough@sallyarmy.org.uk>
Subject: Pattern Matching Problem
Message-Id: <i_fS5.2932$17.54436@stones>
Hi
Been out and bought a couple of the O'Reilly books (Learning Perl and Perl
Cookbook) but I still can't figure out this pattern matching.
Someone here suggested a module called LWP but this is not used in any of
the books examples. Therefore could someone write a example Perl program
that will extract out the third verse out of the Clash song as if it was
actually a text file at http://www.theclash.com/safe.txt please.
Last line of 2nd verse is I DON'T WANNA GO BACK THERE AGAIN and first line
of 4th verse is NOW THEY GOT THE SUN, AN' THEY GOT THE PALM TREES so
basically I want to display what text is between these two lines as an SSI.
If anyone has got a better idea to show me how it works then fire away as I
am open to suggestions (of an appropriate nature of course). Also apologies
to anyone who doesn't like The Clash.
Phil
Safe European Home
(Strummer/Jones)
WELL, I JUST GOT BACK AN' I WISH I NEVER LEAVE NOW
WHO DAT MARTIAN ARRIVAL AT THE AIRPORT?
HOW MANY LOCAL DOLLARS FOR A LOCAL ANAESTHETIC?
THE JOHNNY ON THE CORNER WAS A VERY SYMPATHETIC
I WENT TO THE PLACE WHERE EVERY WHITE FACE IS AN
INVITATION TO ROBBERY
AN' SITTING HERE IN MY SAFE EUROPEAN HOME
I DON'T WANNA GO BACK THERE AGAIN
WASN'T I LUCKY N' WOULDN'T IT BE LOVERLY?
SEND US ALL CARDS, AN' HAVE A LAYING IN ON A SUNDAY
I WAS THERE FOR TWO WEEKS, SO HOW COME I NEVER TELL
THAT NATTY DREAD DRINKS AT THE SHERATON HOTEL?
NOW THEY GOT THE SUN, AN' THEY GOT THE PALM TREES
THEY GOT THE WEED, AN' THEY GOT THE TAXIS
WHOA, THE HARDER THEY COME, N' THE HOME OF OL' BLUEBEAT
YES I'D STAY AN' BE A TOURIST BUT I CAN'T TAKE THE GUNPLAY
------------------------------
Date: Mon, 20 Nov 2000 22:38:31 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Pattern Matching Problem
Message-Id: <t1j9v7iok50te7@corp.supernews.com>
In article <i_fS5.2932$17.54436@stones>,
Phil Latio <sleeping.rough@sallyarmy.org.uk> wrote:
: Someone here suggested a module called LWP but this is not used in any of
: the books examples. Therefore could someone write a example Perl program
: that will extract out the third verse out of the Clash song as if it was
: actually a text file at http://www.theclash.com/safe.txt please.
I get a 404 for that URL, so I assume that you have the song in a local
file formatted as in your post and want to extract the third verse.
That's a simple perl program:
#! /usr/bin/perl
use strict;
my $verse = shift;
$/ = "";
while (<>) {
if ($. == $verse) {
print;
last;
}
}
Call it as
% get-verse 3 safe.txt
Read the perlvar manpage if you don't know what $/ and $. mean.
Hope this helps,
Greg
--
The manufacturers of KY Jelly have announced that their product is now fully
Year 2000 compliant. In the light of this they have now renamed it as 'Y2KY
Jelly'. Said a spokesman: "The main benefit of this revision to our product,
is that you can now insert four digits into your date instead of two".
------------------------------
Date: Mon, 20 Nov 2000 19:54:08 GMT
From: Dan Wilga <dwilgaREMOVE@mtholyoke.edu>
Subject: Re: Perl spider performance
Message-Id: <dwilgaREMOVE-DC686B.14533020112000@news.mtholyoke.edu>
In article <8v41k7$202$1@nnrp1.deja.com>, Mario <diab.lito@usa.net> wrote:
> is Perl an acceptable choice for a web spider?
I wrote one which traverses 21,000 files on a local disk in just under 3
hours. Not that bad. Of course, that depends a lot on the i/o and CPU speed of
the machine being used.
As an aside: I'm saying 3 hours to actually parse the files. I've found that
using Berkeley DB to generate a database to hold the results takes another 6
hours on top of that. Obviously, not the fastest thing on the planet. YMMV.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Mon, 20 Nov 2000 19:38:08 GMT
From: n.paulsen@gmx.net
Subject: perlmenu: install question
Message-Id: <3a197d6f.67315424@news.snafu.de>
Hi,
I'am new to perl.
I want install perlmenu.pm. I've got the getcap - thing to run for
demo files.
What does "put" in the following installation instruction mean?
A copy to /usr/local/lib/perl5 ?
Put "perlmenu.pm" (and "menu.pl" if required) with the rest of your
Perl packages (usually in something like "/usr/local/lib/perl5" or
"/usr/local/lib/perl".
TIA,
Nele
------------------------------
Date: Mon, 20 Nov 2000 21:24:21 GMT
From: pape_98@my-deja.com
Subject: Re: Question about Buttons and Subroutines
Message-Id: <8vc4pq$1e0$1@nnrp1.deja.com>
In article <G4883w.F50@news.muni.cz>,
adelton@informatics.muni.cz wrote:
> On Fri, 17 Nov 2000 23:52:00 GMT, pape_98@my-deja.com <pape_98@my-
deja.com> wrote:
>
> > This is the Sub that I want to call.
> > sub add {
>
> [...]
>
> > print end_html;
> > }
> >
> > These are the methods I've tried.
> >
> > $Add->button(name=>'Add', value=>'Add A User', OnClick=>add());
> >
> > $Add->button(text=>'Add A User', command=>add());
> >
> > Both of them give me the same output.
> > They call the Sub without me having to click on the button. i.e the
Sub
> > is called when I get onto the page.
> > Can you tell me what I'm missing here.
>
> You probably want to say
>
> $Add->button(name=>'Add', value=>'Add A User', OnClick=>"add
()");
>
> But note that you cannot call from browser window a subroutine in
> server script this way.
>
Then how do you do it???
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 15 Nov 2000 17:55:13 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: question about reusing a variable from a regex
Message-Id: <G42v41.ECA@news.boeing.com>
In article <8uubrq$2fl$1@zonnetje.nl.uu.net>,
Walter van den Berg <w.berg@NOSPAMPLEASEsamsom.nl> wrote:
>Hi group,
>
>I wanted to know how I can reuse a variable that's been read in a regex.
>
>This line changes a string (puts something in between):
>s/<RD:$level>(.*?)</<RD:$level><gr:$1>$1</oig;
>
>and this wasn't the hard part, could've done this with a texteditor, but now
>I want to reuse $1 in a next regex, like:
>
>s/<RD>/<RD><gr:$1>/oig;
>
>But that doesn't work. Can you tell me how I put $1 into $variable so I can
>reuse it?
>I've already tried
>s/<RD:$level>(.*?)</<RD:$level><gr:($variable = $1)>$1</oig;
>and similar things.
>
If there's a successful match, $1 will have limited
scope: "...to the end of the enclosing BLOCK or eval
string or the next successful pattern match, whichever
comes first" (from: perldoc perlre). That limitation
also invalidates your use of the "o" modifier on the
regex.
So, the key will be to save the backref as soon as
possible *IF* the substitution succeeded, e.g.,
something like,
s/foo(.*?)bar/foo$1baz/gi and my $var = $1;
hth,
--
Charles DeRykus
------------------------------
Date: Mon, 20 Nov 2000 11:24:43 -0800
From: Stuart Vigne <vigne@nhamp.net>
Subject: Re: rearranging a text file
Message-Id: <9927C923DB489BEF.5FCF9FDC1DFB6674.B168F1BDCBBA2202@lp.airnews.net>
On Mon, 20 Nov 2000 13:18:58 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:
>>Using this 25 line file as an example...I want to take line #1 and
>>print it out with line #14 immediately to its right on the same line.
>>Ditto for line #2 & 15, #3 & 16, and so on.
>
>So there are no other empty lines in this file?
>
> while(<>) {
> last if /^$/; #empty line
> push @a, $_;
> }
> while(<>) {
> print shift @a;
> print;
> }
Forgive me, but how to I apply this to my data file? Let's assume the
file is "sample.txt"
And yes, there is only one empty line in this file.
-Stu
------------------------------
Date: Mon, 20 Nov 2000 21:59:32 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: rearranging a text file
Message-Id: <af7j1tochjnnku69l36ev5eadb9eco7tpc@4ax.com>
Stuart Vigne wrote:
>Forgive me, but how to I apply this to my data file? Let's assume the
>file is "sample.txt"
At the top of the script:
@ARGV = 'sample.txt';
This will print to STDOUT, which could well be the "console", if you
haven't redirected it to a file (see below). You can open a file for
output:
open STDOUT, ">rearranged.txt";
Alternatively, with my original script (rearrange.pl), do this at the
command line:
perl rearrange.pl sample.txt >rearranged.txt
--
Bart.
------------------------------
Date: Mon, 20 Nov 2000 21:14:04 GMT
From: rereidy@my-deja.com
Subject: Re: starting a perl script as an NT service
Message-Id: <8vc46j$rn$1@nnrp1.deja.com>
Neil,
According to Ch8 of "Win32 Perl Scripting",you will need to use
SVRANY.exe, INSTSRV.exe, and Win32::Daemon.
The book is a good resource for Windows and Perl together.
Hope this helps.
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
In article <t1ifj7t6ustb0f@corp.supernews.com>,
"Neil Trenholm" <neil@alaweb.com> wrote:
> Hello,
>
> If this is to the wrong group - please redirect me - I have looked for
an NT
> group - and may have missed it/them.
>
> I have looked through all of the perl docs and CPAN and the perl.org
> website - to no avail.
>
> I would like to start a perl script as a Windows NT service. If anyone
has
> any suggestions or ideas I would be very grateful.
>
> Thanks,
> Neil
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 20 Nov 2000 22:21:44 GMT
From: "Graham W. Boyes" <meNOSPAM@toao.net>
Subject: Time of Scripts
Message-Id: <YthS5.27929$df5.605470@news1.crdva1.bc.home.com>
Any ideas on how to figure out how much time a Perl script takes to run? I
tried just having Perl print the date at the beginnig of the scirpt and
again at the end but the seconds always showed the same. Any ideas on
figuring the mileseconds?
TIA
Graham W. Boyes
--
To avoid injury or death, do not remove the cover of this e-mail.
The following has been intentionally left blank:
------------------------------
Date: Mon, 20 Nov 2000 22:32:11 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Time of Scripts
Message-Id: <slrn91j9ib.r2.mgjv@verbruggen.comdyn.com.au>
On Mon, 20 Nov 2000 22:21:44 GMT,
Graham W. Boyes <meNOSPAM@toao.net> wrote:
> Any ideas on how to figure out how much time a Perl script takes to run? I
> tried just having Perl print the date at the beginnig of the scirpt and
> again at the end but the seconds always showed the same. Any ideas on
> figuring the mileseconds?
Have a look at the times() function, described in perlfunc. It
normally has a resolution of hundreths of a second, but that depends
entirely on your system.
Alternatively, you could have a look at the Time::Hires module,
and its gettimeofday() function, available from CPAN. Its useablity,
again, depends on your system.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results
Commercial Dynamics Pty. Ltd. | were negative.
NSW, Australia |
------------------------------
Date: Mon, 20 Nov 2000 17:45:58 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Time of Scripts
Message-Id: <Pine.GSO.4.21.0011201745310.714-100000@crusoe.crusoe.net>
[posted & mailed]
On Nov 20, Graham W. Boyes said:
>Any ideas on how to figure out how much time a Perl script takes to run? I
>tried just having Perl print the date at the beginnig of the scirpt and
>again at the end but the seconds always showed the same. Any ideas on
>figuring the mileseconds?
The standard Benchmark module should help you. perldoc Benchmark
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Mon, 20 Nov 2000 22:21:32 GMT
From: u0107@cheerful.com
Subject: using exec cgi in a perl program
Message-Id: <8vc853$4d5$1@nnrp1.deja.com>
Hello,
The use of "exec cgi" command in an html file requires the renaming of
the file with a "shtml" extension.
My problem is that on my pages, html code is generated on the fly from
cgi-bin directory using a perl program. To explain a little more, the
URL reads something like:
http://www.mysite.com/cgi-bin/myperl.pl?parameter_1=xxx
myperl.pl uses the value of parameter_1 and generates html code based
on the value.
In the generated html code I need to use exec cgi.
Part of the so-generated html code is a few lines of javascript which
collects an inputted value - say a Zip Code - and "exec cgi"'s another
perl program - say "get_zip_decode.pl?entered_zip=99999" - and puts the
value in "document.form_name.field_name.value" which is a javascript
variable.
Hope to hear many innovative solutions in this forum.
Cheers!
Uttam
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 20 Nov 2000 20:46:33 GMT
From: dack@visi.com
Subject: Weird question: has anyone used Perl to parse the Shoutcast XML feed for display to a browser?
Message-Id: <3a198bf3.19656414@news.visi.com>
Any insights or pointers are appreciated. Thanks.
------------------------------
Date: Mon, 20 Nov 2000 21:14:22 GMT
From: akothek@my-deja.com
Subject: writing system error messages to a logfile...
Message-Id: <8vc476$s2$1@nnrp1.deja.com>
newbie q?
i'm trying to run a simple perl program in which the system error
messages (on unix) are written to a logfile...
here's what i do
open(LOGFILE, "> logfile.log">) || die "couldn't open logfile";
print LOGFILE $!
this does not do anything and the error message is written to the
shell...how do i get it to write out (pipe)the message to the
logfile???
thanks,
a
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 4935
**************************************