[17469] in Perl-Users-Digest
Perl-Users Digest, Issue: 4889 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 18:10:55 2000
Date: Tue, 14 Nov 2000 15:10:17 -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: <974243417-v9-i4889@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 14 Nov 2000 Volume: 9 Number: 4889
Today's topics:
Re: Is this possible in Perl? <jboes@eomonitor.com>
Re: Is this possible in Perl? <jboes@eomonitor.com>
Re: Is this possible in Perl? (Garry Williams)
Re: Is this possible in Perl? <crowj@aol.net>
Re: Is this possible in Perl? <aqumsieh@hyperchip.com>
Re: Is this possible in Perl? (Garry Williams)
Re: label not found ? and trailing decimal - still new <ddunham@redwood.taos.com>
Re: Lizard gone? <joe+usenet@sunstarsys.com>
Re: Lizard gone? <godzilla@stomp.stomp.tokyo>
Mail <mesarch@ee.net>
Re: Mail <peter.sundstrom@eds.com>
Re: Newbie recursion question <ianb@ot.com.au>
ODBC <aabdo@fruit.com>
Perl 5.6.0 on NCR MP-RAS ... ANYBODY? doug.hendricks@tnzi.com
Re: Please tell me why this code is wrong (ActiveState <jeff@vpservices.com>
Re: Please tell me why this code is wrong (ActiveState (Garry Williams)
Re: Please tell me why this code is wrong (ActiveState <newsposter@cthulhu.demon.nl>
Re: Please tell me why this code is wrong (ActiveState (Garry Williams)
Re: Please tell me why this code is wrong (ActiveState <jeffp@crusoe.net>
Re: Problems compiling DBI and HP-UX 11.0 fharris@xmission.com
Re: script to print (part of) html page <mtaylorlrim@my-deja.com>
Re: script to print (part of) html page <aks_music@hotmail.com>
Splitting up a regex <mdemello@kennel.ruf.rice.edu>
Re: Splitting up a regex (Sean McAfee)
Re: Splitting up a regex (Garry Williams)
Re: What is P5P? <greg2@surfaid.org>
Re: What's wrong with the script <spewmuffin@my-deja.com>
Re: What's wrong with the script <mcameron@mirusweb.com>
Re: Why doesn't this work? <jboes@eomonitor.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 14 Nov 2000 15:19:57 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: Is this possible in Perl?
Message-Id: <3a11a0c9$0$30005$44a10c7e@news.net-link.net>
Johan Augustsson wrote:
>
> Can I do the following with Perl?
>
> Take some specific data from a logfile (which changes every now and
> then) and put it into a table in a MySQL-database. As soon as the
> logfile is updated with new data I want some of the data to get into my
> table in the database.
Sure, but it's pretty inefficient:
$mod_time = -C 'yourfile.log';
while (1) {
$old_mod_time = $mod_time;
if (($mod_time = -C 'yourfile.log') != $old_mod_time) {
do_some_mysql_stuff;
sleep(1);
}
}
etc. There's no OS-independent way to have your code 'triggered' by a
change to the file system, so you have to loop forever and check it
yourself. Better you should use 'cron' (on Unix-like systems) or
something similar, and have the code wake up periodically to check. On
most Unixes, you can schedule this once a minute, which should be
sufficient for non-realtime systems. (If you're tracking something that
needs to know more than once a minute, you should probably do something
a lot more sophisticated using OS signals of some kind.)
--
Jeff Boes <jboes@eoexchange.com> Tel: (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc. http://www.eoexchange.com/
Search, Monitor, Notify. http://www.eomonitor.com/
------------------------------
Date: Tue, 14 Nov 2000 15:21:25 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: Is this possible in Perl?
Message-Id: <3a11a0cb$0$30005$44a10c7e@news.net-link.net>
Ala Qumsieh wrote:
>
> Johan Augustsson <johan.augustsson@adm.gu.se> writes:
>
> > Can I do the following with Perl?
<snip>
> Yes, you can do this with Perl.
>
> --Ala
Haw, haw! You funny guy! Whew, that's hilarious.
--
Jeff Boes <jboes@eoexchange.com> Tel: (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc. http://www.eoexchange.com/
Search, Monitor, Notify. http://www.eomonitor.com/
------------------------------
Date: Tue, 14 Nov 2000 20:54:26 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Is this possible in Perl?
Message-Id: <6EhQ5.487$xb1.28908@eagle.america.net>
On Tue, 14 Nov 2000 15:19:57 -0500, Jeff Boes <jboes@eomonitor.com> wrote:
>Johan Augustsson wrote:
>>
>> Can I do the following with Perl?
>>
>> Take some specific data from a logfile (which changes every now and
>> then) and put it into a table in a MySQL-database. As soon as the
>> logfile is updated with new data I want some of the data to get into my
>> table in the database.
>
>Sure, but it's pretty inefficient:
[snip]
>etc. There's no OS-independent way to have your code 'triggered' by a
>change to the file system, so you have to loop forever and check it
>yourself. Better you should use 'cron' (on Unix-like systems) or
>something similar, and have the code wake up periodically to check. On
>most Unixes, you can schedule this once a minute, which should be
>sufficient for non-realtime systems. (If you're tracking something that
>needs to know more than once a minute, you should probably do something
>a lot more sophisticated using OS signals of some kind.)
Hmmm. If you're suggesting Unix-only solutions, then just open a pipe
from tail and block on reading it in a loop:
open(LOG, "tail -f logfile|") || die "can't fork tail: $!";
while ( <LOG> ) {
# Process the new record written to the log file
}
--
Garry Williams
------------------------------
Date: Tue, 14 Nov 2000 17:19:14 -0500
From: John Crowley <crowj@aol.net>
Subject: Re: Is this possible in Perl?
Message-Id: <3A11BA62.4A2D72EF@aol.net>
Garry Williams wrote:
>
> On Tue, 14 Nov 2000 15:19:57 -0500, Jeff Boes <jboes@eomonitor.com> wrote:
> >Johan Augustsson wrote:
> >>
> >> Can I do the following with Perl?
> >>
> >> Take some specific data from a logfile (which changes every now and
> >> then) and put it into a table in a MySQL-database. As soon as the
> >> logfile is updated with new data I want some of the data to get into my
> >> table in the database.
> >
> >Sure, but it's pretty inefficient:
> [snip]
> >etc. There's no OS-independent way to have your code 'triggered' by a
> >change to the file system, so you have to loop forever and check it
> >yourself. Better you should use 'cron' (on Unix-like systems) or
> >something similar, and have the code wake up periodically to check. On
> >most Unixes, you can schedule this once a minute, which should be
> >sufficient for non-realtime systems. (If you're tracking something that
> >needs to know more than once a minute, you should probably do something
> >a lot more sophisticated using OS signals of some kind.)
>
> Hmmm. If you're suggesting Unix-only solutions, then just open a pipe
> from tail and block on reading it in a loop:
>
> open(LOG, "tail -f logfile|") || die "can't fork tail: $!";
> while ( <LOG> ) {
> # Process the new record written to the log file
> }
>
> --
> Garry Williams
only one problem ... the loop will never end because tail -f doesn't
provide an EOF.
Consider (and run) the following:
#!/usr/bin/perl
my @data = qw (the quick brown fox jumped over the lazy dog);
open (X, ">foo.txt") or die "d'oh";
foreach (@data) {
print X "$_\n";
}
close (X);
# yes, this will print @data but then will hang
open (Y, "tail -f foo.txt|") or die "d'oh";
while (<Y>) {
chomp;
print "$_\n";
}
close (Y);
------------------------------
Date: Tue, 14 Nov 2000 22:33:45 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Is this possible in Perl?
Message-Id: <7ad7fy6v5h.fsf@merlin.hyperchip.com>
Jeff Boes <jboes@eomonitor.com> writes:
> Ala Qumsieh wrote:
> >
> > Johan Augustsson <johan.augustsson@adm.gu.se> writes:
> >
> > > Can I do the following with Perl?
>
> <snip>
>
> > Yes, you can do this with Perl.
> >
> > --Ala
>
> Haw, haw! You funny guy! Whew, that's hilarious.
I wasn't trying to be funny or even sarcastic, unlike you. The OP asked
a question. I didn't know his intentions. Maybe he wanted a complete
Perl program that does what he wants, or maybe he wanted a pointer as to
whether this is possible or not in Perl, in which case he would decide
whether it was worthwhile to look into Perl or not.
I replied based on the question asked, and had the OP replied with a
more detailed question, I would've answered appropriately, if I were
capable of doing so. Again, I wasn't trying to be sarcastic. Please have
a look at my posting history (which hasn't been up to speed lately due
to work load) and then judge accordingly.
I believe that my post, although very short, served a good purpose. On
the other hand, your post had no real reason, and just wasted more
bandwith. I appreciate your efforts at helping others on this forum, and
I think that your posts are of a good quality. But still, you shouldn't
be jumping too quickly to conclusions.
--Ala
------------------------------
Date: Tue, 14 Nov 2000 22:57:51 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Is this possible in Perl?
Message-Id: <PrjQ5.506$xb1.29424@eagle.america.net>
On Tue, 14 Nov 2000 17:19:14 -0500, John Crowley <crowj@aol.net>
wrote:
>Garry Williams wrote:
>> On Tue, 14 Nov 2000 15:19:57 -0500, Jeff Boes <jboes@eomonitor.com>
>> wrote:
>> >Johan Augustsson wrote:
>> >>
>> >> Can I do the following with Perl?
>> >>
>> >> Take some specific data from a logfile (which changes every now and
>> >> then) and put it into a table in a MySQL-database. As soon as the
>> >> logfile is updated with new data I want some of the data to get into my
>> >> table in the database.
>> >
>> >Sure, but it's pretty inefficient:
>> [snip]
>> >etc. There's no OS-independent way to have your code 'triggered' by a
>> >change to the file system, so you have to loop forever and check it
>> >yourself. Better you should use 'cron' (on Unix-like systems) or
>> >something similar, and have the code wake up periodically to check. On
>> >most Unixes, you can schedule this once a minute, which should be
>> >sufficient for non-realtime systems. (If you're tracking something that
>> >needs to know more than once a minute, you should probably do something
>> >a lot more sophisticated using OS signals of some kind.)
>>
>> Hmmm. If you're suggesting Unix-only solutions, then just open a pipe
>> from tail and block on reading it in a loop:
>>
>> open(LOG, "tail -f logfile|") || die "can't fork tail: $!";
>> while ( <LOG> ) {
>> # Process the new record written to the log file
>> }
>
>only one problem ... the loop will never end because tail -f doesn't
>provide an EOF.
The poster didn't make it clear that this was a requirement, but you
have a point.
$SIG{TERM} = \&stop;
$SIG{QUIT} = \&stop;
$SIG{HUP} = \&stop;
$SIG{INT} = \&stop;
sub stop {
warn "$0 caught SIG", shift, " -- exiting...\n";
exit(0);
}
Now this script documents why it's exiting. That may be sufficient.
Another approach could be as suggested by Jeff Boes to adopt some sort
of signalling protocol between this script and the program writing to
the log. The logging program could signal this program as it exited.
It could do that by sending a signal to the PID that this program
records in an agreed-upon file.
Another approach could be for the logging program to flock a semaphore
file exclusively. This program could attempt a non-blocking exclusive
flock of the semaphore at the end of its while loop and exit when
flock returns no error or not EWOULDBLOCK (an error).
I guess it depends...
It's not certain that an unending script is not going to work for the
original poster.
That's a bunch of negatives, eh? Does that always happen when
requirements are not clear?
--
Garry Williams
------------------------------
Date: Tue, 14 Nov 2000 19:19:55 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: label not found ? and trailing decimal - still new at this
Message-Id: <vfgQ5.138$Z84.33608@news.pacbell.net>
msalerno@my-deja.com wrote:
> Sorry about posting the entire script, but I didn't know where the best
> place to cut would be. Please all keep in mind that I am still very
> new at this. The issue is that I need the script to validate Ip
> addresses. I cannot get the script to recognize labels with "next".
> If I change the "next" to a "goto" it will work. But I don't want a
> goto ! Also if I enter the ip address of "10.10.10.10." it accepts it,
> the trailing decimal should be read as an error. Please let me know
> where I have gone wrong.
You have three independent loops...
for (..) { }
for (..) { }
for (..)
They don't need labels. You cannot jump from one loop to another.
Labels are used in nested loops like this...
L1: for (..)
{ L2: for (..)
{ next;
}
}
Notice the ambiguity of the next. Does it next the inner loop or the
outer loop? By default it will next the inner loop, but a 'next L1'
would have it next the outer loop instead.
So, to do what you want, you need to move your third loop around the
first two
for (1..3)
{
for (1..3) { get first ip}
for (1..3) { get second ip}
}
PS. I found your code difficult to read because the indentation is
almost nonexistent and quite inconsistent. Indenting isn't something to
ignore. It's a programming technique that can minimize many mistakes.
If you find it difficult to maintain your own indentation, try using an
editor that will help you with it.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< Please move on, ...nothing to see here, please disperse >
------------------------------
Date: 14 Nov 2000 15:27:58 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Lizard gone?
Message-Id: <m33dguqoxd.fsf@mumonkan.sunstarsys.com>
Jeff Boes <jboes@eomonitor.com> writes:
> Looks like our local lizard is on vacation, eh? No posts here since
> 10/30...
>
No, but (s)he's probably pursuaded NS to release a browser in
his/her honor that's not backwards compatible with anything
else they've released.
I guess that's a good thing ;)
--
Joe Schaefer
------------------------------
Date: Tue, 14 Nov 2000 12:38:55 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Lizard gone?
Message-Id: <3A11A2DF.405C18C1@stomp.stomp.tokyo>
Jeff Boes pensively whined:
> Looks like our local lizard is on vacation, eh?
> No posts here since 10/30...
Snow skiing season has finally arrived.
Shirley you wouldn't expect me to hang
around with you Techno-Geeksters rather
than extreme ski with my Little Lizard.
Godzilla!
http://la.znet.com/~callgirl/extreme.cgi
------------------------------
Date: Tue, 14 Nov 2000 15:48:07 -0500
From: "Mike Mesarch" <mesarch@ee.net>
Subject: Mail
Message-Id: <8us8gt$29i$1@sshuraab-i-1.production.compuserve.com>
Can someone provide me with some code to send a mail message in perl.
Typically I don't ask for something like this, but I have searched to no
avail on how to do this. In the doco it suggests using sendmail
Mail:Mailer. All i want to do is connect to a mail server
(smtp.something.com) and send a message. I haven't seen anything to do
this.
Thanks!
Mike
------------------------------
Date: Wed, 15 Nov 2000 11:41:20 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Mail
Message-Id: <8usf8a$ar1$1@hermes.nz.eds.com>
Mike Mesarch <mesarch@ee.net> wrote in message
news:8us8gt$29i$1@sshuraab-i-1.production.compuserve.com...
> Can someone provide me with some code to send a mail message in perl.
> Typically I don't ask for something like this, but I have searched to no
> avail on how to do this. In the doco it suggests using sendmail
> Mail:Mailer. All i want to do is connect to a mail server
> (smtp.something.com) and send a message. I haven't seen anything to do
> this.
There are lots of modules to do this. Check out the following list on CPAN
MailTools
Mail-Sender
Mail-Sendmail
MIME-Lite
------------------------------
Date: Wed, 15 Nov 2000 09:03:55 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: Newbie recursion question
Message-Id: <3A11B6CB.85EC0B87@ot.com.au>
Kai Jang wrote:
> > > >sub showit {
> > > > &showit($_[0]);
> > > > push (@dirs, $_) if ((-d $_) && ($_ !~m/^\.$/));
> > > > push (@files, $_) if (-f $_);
> > > >}
>
> The problem is that it is giving me that deep recursion error. I am
> wondering if maybe there is a better way out there to print out the
> whole directory tree. Maybe chdir??? Any ideas??? Thanks...
They were telling you what the problem was, but they were too subtle for
you. Your sub is designed to cause the error you are getting. Deep
recursion is an indication that you are in an infinite loop. You are.
When you call your sub, it immediately calls itself, and then
immediately calls itself, and then... Recursion is only useful if you
can break out of it at some stage, and you don't.
You need to change some state somewhere before calling the sub again,
and you need to change it in a way that subsequent calls converge on the
solution you are looking for. And when you hit the end, you need to stop
calling your sub, and return all the way down the stack.
Regards,
Ian
------------------------------
Date: Tue, 14 Nov 2000 15:53:32 -0600
From: Antonio Abdo <aabdo@fruit.com>
Subject: ODBC
Message-Id: <3A11B45B.895B6DF6@fruit.com>
A newbie to Perl, I want every trick written in Perl on how to connect
to an AS400 using an NT server that does not give us the following
message:
rntvar=2
Cannot connect to:[IBM]Client Access ODBC Driver(32-bit)[DB2/400SQL]
Communication link failure. COMM RC=0x3(SQL-08S01)(DBD:db_login/SQL
Connect err=-1):
runs OK on a command line but not on an NT server? Got IBM trying to
figure this out too!
got the Perl program to run successfully and connect to an AS400 using
an Apache server freeware installed onto my desktop!
Any clues would be appreciated!
Tony Abdo
MIS
------------------------------
Date: Tue, 14 Nov 2000 21:50:15 GMT
From: doug.hendricks@tnzi.com
Subject: Perl 5.6.0 on NCR MP-RAS ... ANYBODY?
Message-Id: <8usc2k$oqu$1@nnrp1.deja.com>
Months ago, I spent days attempting to install Perl 5.6.0 on an NCR
server running MP-RAS 3.02 unix. I posted to perlbugs and p5p and this
newsgroup. Other than a few kind hints that didn't work and messages
from other lost souls in NCR land, the silence was deafening.
I've tried gnumake, which didn't help. At least one fairly bright perl
person was feeding me hints, but none worked.
Has ANYBODY EVER succeeded installing Perl 5.6.0 on MP-RAS? EVER?
Earlier versions of Perl were pretty easy once you realised that nm was
not your friend.
Please email me as I rarely enter this group. I think you can
understand why, as there seemed to be very few NCR MP-RAS users left.
We are currently in a project to move our most important systems off
this platform. I would still like to get Perl5.6.0/NCR working, as for
a long time we will be running NCR and its replacement, and one Perl
version across the site would be nice.
doug.hendricks@tnzi.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 13:31:43 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <3A11AF3F.6A13D3C2@vpservices.com>
dsteuber@my-deja.com wrote:
>
> I have a compile error that I do not understand. I have reduced
> my code to the following short example. I am trying to run it on
> an NT box, but I wrote it like a Unix Perl program out of habit.
This has nothing to do with what OS you are running on.
> my $foo_hash_ref = Foo::get_foo_hash();
>
> printf "%s\n", $foo_hash_ref{bar};
>
> Global symbol "%foo_hash_ref" requires explicit package name at test.pl
> line 16.
You forgot to de-reference $foo_hash_ref. When you write
"$foo_hash_ref{bar} you are treating the hashref as if it were a plain
hash. Walk down to the corner drugstore and buy yourself an arrow.
--
Jeff
------------------------------
Date: Tue, 14 Nov 2000 21:49:31 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <LriQ5.496$xb1.29054@eagle.america.net>
On Tue, 14 Nov 2000 21:03:33 GMT, dsteuber@my-deja.com
<dsteuber@my-deja.com> wrote:
>I have a compile error that I do not understand. I have reduced
>my code to the following short example. I am trying to run it on
>an NT box, but I wrote it like a Unix Perl program out of habit.
>
>------------------------------------------------------------
>#!/usr/bin/perl -w
>use strict;
>
>package Foo;
>
>my %foo_hash = { bar => "baz" };
>
>sub get_foo_hash {
> return \%foo_hash;
>}
If this ever got a chance to be executed, it would have produced the
warning: "Reference found where even-sized list expected at...". I
suspect what you really meant to do is:
my %foo_hash = ( bar => "baz" );
instead of the anonymous hash reference.
>package main;
>
>my $foo_hash_ref = Foo::get_foo_hash();
>
>printf "%s\n", $foo_hash_ref{bar};
>
>exit(0);
You declare a *scalar* $foo_hash_ref; okay. Then you use an
undeclared *hash*; not okay, hence the compile-time error. I suspect
that you really meant to do:
printf "%s\n", $foo_hash_ref->{bar};
--
Garry Williams
------------------------------
Date: 14 Nov 2000 21:48:13 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <8usbut$8ii$1@internal-news.uu.net>
dsteuber@my-deja.com wrote:
> my %foo_hash = { bar => "baz" };
And to answer the next question:
Reference found where even-sized list expected at test.pl line 6.
use %hash = (...) instead of %hash = {...}
Erik
------------------------------
Date: Tue, 14 Nov 2000 22:32:59 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <v4jQ5.504$xb1.29166@eagle.america.net>
On Tue, 14 Nov 2000 17:06:27 -0500, Jeff Pinyan <jeffp@crusoe.net>
wrote:
>On Nov 14, dsteuber@my-deja.com said:
>
>>my %foo_hash = { bar => "baz" };
>
>This is incorrect. You want (...) instead of {...}. Next time, run Perl
>with the -w switch turned on.
Not sure why you think this wasn't done, but it will make no
difference. The code will compile without any warnings. However, at
*run time*, it will generate the warning "Reference found where
even-sized list expected at...", if warnings are enabled. The
original poster's code never made it to run time due to the compile
time error that you correctly explained.
--
Garry Williams
------------------------------
Date: Tue, 14 Nov 2000 17:06:27 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <Pine.GSO.4.21.0011141701310.25361-100000@crusoe.crusoe.net>
[posted & mailed]
On Nov 14, dsteuber@my-deja.com said:
>my %foo_hash = { bar => "baz" };
This is incorrect. You want (...) instead of {...}. Next time, run Perl
with the -w switch turned on.
>my $foo_hash_ref = Foo::get_foo_hash();
>printf "%s\n", $foo_hash_ref{bar};
>Global symbol "%foo_hash_ref" requires explicit package name at test.pl
>line 16.
That's because you defined $foo_hash_ref, but not %foo_hash_ref. You're
accessing the 'bar' key in %foo_hash_ref, instead of the 'bar' key in the
hash reference $foo_hash_ref. Try:
print $foo_hash_ref->{bar};
--
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: Tue, 14 Nov 2000 21:28:40 GMT
From: fharris@xmission.com
Subject: Re: Problems compiling DBI and HP-UX 11.0
Message-Id: <3a11ae0a.1121236893@news.xmission.com>
On Tue, 14 Nov 2000 02:33:58 GMT, quagly <quagly@home.com> wrote:
>Frank Harris wrote:
>
>> I'm having a heck of a time trying to get DBI to compile with my HP-UX
>> 11 system. I am guessing that the version of CC on the system isn't
>> exactly ANSI compliant, so I went ahead and installed GCC without any
>> troubles. Now I receive this message when I compile DBI using GCC:
>>
>> /opt/gcc/bin/gcc -c -Ae -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O
>> +Onolimit -DVERSION=\"1.14\" -DXS_VERSION=\"1.14\" +z
>> -I/opt/perl5/lib/5.6.0/PA-RISC1.1/CORE -DDBI_NO_THREADS Perl.c
>> gcc: +Onolimit: No such file or directory
>> gcc: +z: No such file or directory
>> *Initialization*:1: missing token-sequence in `#assert'
>> *** Error exit code 1
>>
>> Stop.
>>
>> -----------------------------------------
>> Any ideas how to fix this problem?
>>
>> Any help that can be provided on this issue would be greatly
>> appreciated.
>>
>> Thanks,
>> Frank
>
>This is a known HP/DBI problem. We had to link DBI/DBD statically to get
>it to work.
Interesting. Do you have or know where I can find the static DBI/DBD
package for HP? I would very much appreciate any help.
Thanks,
Frank
------------------------------
Date: Tue, 14 Nov 2000 19:15:21 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: script to print (part of) html page
Message-Id: <8us2vv$g87$1@nnrp1.deja.com>
In article <8urrvr$cmt$1@news.gte.com>,
"Larry Steinberg" <larry.steinberg@verizon.com> wrote:
> Hi,
>
> Does anyone have or know of a perl script that will allow a user to
print an
> html page (or part of one). Thanks in advance.
>
> ls
>
>
It's not perl, and may not even be what your looking for, especially in
this newsgroup...
<SCRIPT Language="Javascript">
var NS = (navigator.appName == "Netscape");
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3) {
document.write('<form><input type=button value="Print this Page"
name="Print" onClick="printit()"></form>');
}
</script>
But it may not work for you for what your doing...
Mark
--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 21:15:32 GMT
From: =?iso-8859-1?Q?=D0=2DVolta?= PCP <aks_music@hotmail.com>
Subject: Re: script to print (part of) html page
Message-Id: <3A11A915.1944553F@hotmail.com>
#!/usr/bin/perl -w
# print_html.cgi
# by Ð-Volta PCP
# This script will print out an html page in a browser while the location
# will still read http://www.yourhost.com/yourcgi-binpath/print_html.cgi
# change to the path on your unix box to the html file you want to print
$html_page_to_print = '../lone_wolf.htm';
print "Content-type: text/html\n\n";
open(FILE,"<$html_page_to_print") or die "Cannot open file: $!\n";
@stdr = <FILE>;
close (FILE);
print @stdr;
# When you go to the url: http://www.host.com/yourcgipath/print_html.cgi
# in your browser, the page you put in $html_page_to_print will open.
# The address should still read .../print_html.cgi
# you should hard code all linked objects; images, links, sound files ... in the
htm document.
Larry Steinberg wrote:
> Hi,
>
> Does anyone have or know of a perl script that will allow a user to print an
> html page (or part of one). Thanks in advance.
>
> ls
------------------------------
Date: 14 Nov 2000 20:51:57 GMT
From: Martin Julian DeMello <mdemello@kennel.ruf.rice.edu>
Subject: Splitting up a regex
Message-Id: <8us8ld$dep$1@joe.rice.edu>
I have a piece of code that needs to trigger on lines starting with certain
strings.
Right now I'm using
if (($_ =~ /^(Number of events|Total CPU time|Max Agent time)/)) { }
which works nicely. However, I can't manage to split it up so that there's
only one string per line (for readability's sake; I need to add more cases
and it's spilling over 80 chars) - I tried using /x but it didn't work.
I'd like something like the following (non working) code:
if ($_ =~ /^(Number of events|
nBytes|
Total Real time|
Total CPU time|
Max Agent time)/x
)
Any ideas? Or is there a neater way to do this?
--
Martin DeMello
------------------------------
Date: Tue, 14 Nov 2000 21:54:33 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Splitting up a regex
Message-Id: <twiQ5.9355$O5.223377@news.itd.umich.edu>
In article <8us8ld$dep$1@joe.rice.edu>,
Martin Julian DeMello <mdemello@kennel.ruf.rice.edu> wrote:
>I have a piece of code that needs to trigger on lines starting with certain
>strings.
>Right now I'm using
> if (($_ =~ /^(Number of events|Total CPU time|Max Agent time)/)) { }
>which works nicely. However, I can't manage to split it up so that there's
>only one string per line (for readability's sake; I need to add more cases
>and it's spilling over 80 chars) - I tried using /x but it didn't work.
>I'd like something like the following (non working) code:
> if ($_ =~ /^(Number of events|
> nBytes|
> Total Real time|
> Total CPU time|
> Max Agent time)/x
> )
>
>Any ideas? Or is there a neater way to do this?
When using the /x modifier, you have to escape whitespace to be matched:
if ($_ =~ /^(Number\ of\ events|
nBytes|
Total\ Real\ Time|
Total\ CPU\ time|
Max\ Agent\ time)/x) { }
Not much better, is it?
Personally, I tend to balk at using regexen to match exact strings, since
eq does it so much faster. In a situation like this I would probably
use a closure:
sub match_beginning_of_line {
my @prefixes = @_;
sub {
my $string = shift;
foreach my $prefix (@prefixes) {
return 1 if substr($string, 0, length($prefix)) eq $prefix;
}
return 0;
}
}
my $matchsub = match_beginning_of_line(
'Number of events',
'nBytes',
'Total Real time',
'Total CPU time',
'Max Agent time'
);
if ($matchsub->($_)) {
# whatever
}
Now you can easily change the list of strings to be matched without
twiddling a regex, and you can easily define additional lists of prefixes
to match.
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Tue, 14 Nov 2000 22:25:13 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Splitting up a regex
Message-Id: <dZiQ5.503$xb1.29166@eagle.america.net>
On 14 Nov 2000 20:51:57 GMT, Martin Julian DeMello
<mdemello@kennel.ruf.rice.edu> wrote:
>I'd like something like the following (non working) code:
> if ($_ =~ /^(Number of events|
> nBytes|
> Total Real time|
> Total CPU time|
> Max Agent time)/x
> )
When /x is used for a match or substitute, *all* white space is
ignored. Escape the space characters that you intend to be part of
the actual pattern.
It's actually discussed in the perlop manual page under the section
"Gory details of parsing quoted constructs". That section's title is
apt. :-)
--
Garry Williams
------------------------------
Date: Tue, 14 Nov 2000 21:19:46 +0000
From: Greg Griffiths <greg2@surfaid.org>
Subject: Re: What is P5P?
Message-Id: <3A11AC72.B877AC17@surfaid.org>
P5P is the Perl 5 Porters, they are the people who help develop the core
releases of the language and keep it all working.
Peter BARABAS wrote:
> EHLO,
>
> I'm interested in what P5P is.
>
> Thanks in advance.
>
> Regards,
> Peter BARABAS.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 20:46:09 GMT
From: SpewMuffin <spewmuffin@my-deja.com>
Subject: Re: What's wrong with the script
Message-Id: <8us8ae$l7g$1@nnrp1.deja.com>
In article <3A11AC49.E941152E@3web.net>,
iryna martynenko <irynam@3web.net> wrote:
> Can anybody help me with this script.
> When I launch it from the HTML page I got a message "the document
> contain no data"
> What's wrong with it.
> I would appreciate it if your could give me a clue how to solve the
> problem
>
> Thank in advance
> ====================================================
> #!/usr/bin/perl
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $FORM{$name} = $value;
> }
>
> if($FORM{'month'} eq "november" & $FORM{'year'} == 2000)
> {print "Location: http://www.blabla.net/page2.html"}
> elsif ($FORM{'month'} eq "december" & $FORM{'year'} == 2000)
> {print "Location: http://www.blabla.net/page3.html"}
> elsif ($FORM{'month'} eq "january" & $FORM{'year'} == 2001)
> {print "Location: http://www.blabla.net/page4.html"}
> elsif ($FORM{'month'} eq "february" & $FORM{'year'} == 2001)
> {print "Location: http://www.blabla.net/page5.html"}
> else {print "Location: http://www.blabla.net/page6.html"}
> exit;
>
> HTML codes
> ****************
...
It appears that the context header is missing, the part where the CGI
tells the web browser to print to the browser. Unless I'm mistaken,
shouldn't there be a
print ("Content-type: text/html\n\n");
as the second line right after the execution of the perl script
(#!/usr/bin/local/perl)?
--
SpewMuffin; E-mail: spewmuffin@my-deja.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 22:11:35 GMT
From: Mike Cameron <mcameron@mirusweb.com>
Subject: Re: What's wrong with the script
Message-Id: <3A11C6C0.5A000F86@mirusweb.com>
--------------55A4DB53F6DB7C72FF70BC9C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
If I see things correctly you are getting the error because nothing is
sent to the browser. You need to terminate the header with \n\n in
order for it to do the redirection. Do not print 'Content-type:
text/html\n\n' unless you want the browser to display the text Location:
http://www.blabla.net/page2.html
iryna martynenko wrote:
> Can anybody help me with this script.
> When I launch it from the HTML page I got a message "the document
> contain no data"
> What's wrong with it.
> I would appreciate it if your could give me a clue how to solve the
> problem
>
> Thank in advance
> ====================================================
> #!/usr/bin/perl
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $FORM{$name} = $value;
> }
>
> if($FORM{'month'} eq "november" & $FORM{'year'} == 2000)
> {print "Location: http://www.blabla.net/page2.html"}
> elsif ($FORM{'month'} eq "december" & $FORM{'year'} == 2000)
> {print "Location: http://www.blabla.net/page3.html"}
> elsif ($FORM{'month'} eq "january" & $FORM{'year'} == 2001)
> {print "Location: http://www.blabla.net/page4.html"}
> elsif ($FORM{'month'} eq "february" & $FORM{'year'} == 2001)
> {print "Location: http://www.blabla.net/page5.html"}
> else {print "Location: http://www.blabla.net/page6.html"}
> exit;
>
> HTML codes
> ****************
> <form method="POST" action="http://www.blabla.net/cgi-bin/menu.cgi">
> <select name="month">
> <option value="november">november
> <option value="december">december
> <option value="january">jenuary
> <option value="february">february
> </select>
> <select name="year">
> <option value="2000">2000
> <option value="2001">2001
> </select> <input type=submit value="Open">
> </font>
> </form>
>
--------------55A4DB53F6DB7C72FF70BC9C
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
If I see things correctly you are getting the error because nothing is
sent to the browser. You need to terminate the header with \n\n in
order for it to do the redirection. Do not print 'Content-type: text/html\n\n'
unless you want the browser to display the text Location: <font size=-1><a href="http://www.blabla.net/page2.html">http://www.blabla.net/page2.html</a></font>
<p>iryna martynenko wrote:
<blockquote TYPE=CITE><font size=-1>Can anybody help me with this script.</font>
<br><font size=-1>When I launch it from the HTML page I got a message "the
document contain no data"</font>
<br><font size=-1>What's wrong with it.</font>
<br><font size=-1>I would appreciate it if your could give me a clue how
to solve the problem</font>
<p><font size=-1>Thank in advance</font>
<br><font size=-1>====================================================</font>
<br><font size=-1>#!/usr/bin/perl</font>
<br><font size=-1>read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});</font>
<br><font size=-1>@pairs = split(/&/, $buffer);</font>
<br><font size=-1>foreach $pair (@pairs) {</font>
<br><font size=-1> ($name, $value) = split(/=/, $pair);</font>
<br><font size=-1> $value =~ tr/+/ /;</font>
<br><font size=-1> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/eg;</font>
<br><font size=-1> $FORM{$name} = $value;</font>
<br><font size=-1>}</font>
<p><font size=-1> if($FORM{'month'} eq "november" & $FORM{'year'}
== 2000)</font>
<br><font size=-1> {print "Location:
<a href="http://www.blabla.net/page2.html">http://www.blabla.net/page2.html</a>"}</font>
<br><font size=-1> elsif ($FORM{'month'} eq "december" &
$FORM{'year'} == 2000)</font>
<br><font size=-1> {print "Location:
<a href="http://www.blabla.net/page3.html">http://www.blabla.net/page3.html</a>"}</font>
<br><font size=-1> elsif ($FORM{'month'} eq "january" &
$FORM{'year'} == 2001)</font>
<br><font size=-1> {print "Location:
<a href="http://www.blabla.net/page4.html">http://www.blabla.net/page4.html</a>"}</font>
<br><font size=-1> elsif ($FORM{'month'} eq "february" &
$FORM{'year'} == 2001)</font>
<br><font size=-1> {print "Location:
<a href="http://www.blabla.net/page5.html">http://www.blabla.net/page5.html</a>"}</font>
<br><font size=-1> else {print "Location: <a href="http://www.blabla.net/page6.html">http://www.blabla.net/page6.html</a>"}</font>
<br><font size=-1>exit;</font>
<p><font size=-1>HTML codes</font>
<br><font size=-1>****************</font>
<br><font size=-1><form method="POST" action="<a href="http://www.blabla.net/cgi-bin/menu.cgi">http://www.blabla.net/cgi-bin/menu.cgi</a>"></font>
<br><font size=-1> <select name="month"></font>
<br><font size=-1><option value="november">november</font>
<br><font size=-1><option value="december">december</font>
<br><font size=-1><option value="january">jenuary</font>
<br><font size=-1><option value="february">february</font>
<br><font size=-1></select></font>
<br><font size=-1><select name="year"></font>
<br><font size=-1><option value="2000">2000</font>
<br><font size=-1><option value="2001">2001</font>
<br><font size=-1></select> <input type=submit value="Open"></font>
<br><font size=-1> </font></font>
<br><font size=-1> </form></font>
<br> </blockquote>
</html>
--------------55A4DB53F6DB7C72FF70BC9C--
------------------------------
Date: Tue, 14 Nov 2000 15:26:23 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: Why doesn't this work?
Message-Id: <3a11a0cc$0$30005$44a10c7e@news.net-link.net>
Glenn Tillema wrote:
>
> together using a CGI program.
<snip>
> get the command to work via the command line without any problems!
<snip>
> system("/usr/bin/tiffcp $files /tmp/combined$$.tif");
<snippity-snip>
1) CGI code runs as the webserver, not the user.
2) 9/10 times, this problem is caused by file permissions.
3) You need to add the following URLs to your bookmark list, and study
them.
ftp://ftp.epix.net/pub/languages/perl/doc/FAQs/cgi/idiots-guide.html
http://perlmonth.com/columns/begin/begin.html?issue=11
--
Jeff Boes <jboes@eoexchange.com> Tel: (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc. http://www.eoexchange.com/
Search, Monitor, Notify. http://www.eomonitor.com/
------------------------------
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 4889
**************************************