[23516] in Perl-Users-Digest
Perl-Users Digest, Issue: 5726 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 29 14:10:52 2003
Date: Wed, 29 Oct 2003 11:10:15 -0800 (PST)
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, 29 Oct 2003 Volume: 10 Number: 5726
Today's topics:
Java with apache from perl script? (i5513)
Re: Java with apache from perl script? <usenet@morrow.me.uk>
Re: Java with apache from perl script? <grazz@pobox.com>
job: perl script for authorize.net AIM (advanced integr (dave the spazz)
Re: multiline regular expression, is it possible? (Bill)
Re: multiline regular expression, is it possible? <usenet@morrow.me.uk>
Re: Resetting //g <pinyaj@rpi.edu>
Re: Singleton process (Mark Jason Dominus)
Re: Singleton process <usenet@morrow.me.uk>
tie problem (Richard)
Re: tie problem <usenet@morrow.me.uk>
What am I doing wrong?! (Tony Walker)
Re: What am I doing wrong?! <jurgenex@hotmail.com>
Re: What am I doing wrong?! <tore@aursand.no>
Re: What am I doing wrong?! <mbudash@sonic.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Oct 2003 09:26:16 -0800
From: i5513@hotmail.com (i5513)
Subject: Java with apache from perl script?
Message-Id: <a657ec02.0310290926.56312436@posting.google.com>
Hi, I'm running Apache server with mod_perl active.
I can run my script from command line and all is fine, but when I run
my script from navigator, it doesn't run fine because my script is:
...
system "java program_java";
...
How can I do Apache to run java programs?
Thanks you, I read on google about Tomcat and about Apache Jserver,
but I don't know where can I start.
PD: I'm sorry for my poor english.
------------------------------
Date: Wed, 29 Oct 2003 17:42:47 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Java with apache from perl script?
Message-Id: <bnou6n$k9a$3@wisteria.csv.warwick.ac.uk>
i5513@hotmail.com (i5513) wrote:
> Hi, I'm running Apache server with mod_perl active.
>
> I can run my script from command line and all is fine, but when I run
> my script from navigator, it doesn't run fine because my script is:
>
> ...
> system "java program_java";
> ...
>
> How can I do Apache to run java programs?
Not like that. Not, in fact, using Perl at all.
> Thanks you, I read on google about Tomcat and about Apache Jserver,
> but I don't know where can I start.
Start in an Apache or Java newsgroup.
Ben
--
It will be seen... that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher arises among them who... convinc[es] them that their
...institutions are not based on... morality. [Samuel Butler] ben@morrow.me.uk
------------------------------
Date: Wed, 29 Oct 2003 18:19:25 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Java with apache from perl script?
Message-Id: <NwTnb.29756$4O1.6714@nwrdny01.gnilink.net>
Ben Morrow <usenet@morrow.me.uk> wrote:
> i5513@hotmail.com (i5513) wrote:
> > I can run my script from command line and all is fine, but when I run
> > my script from navigator, it doesn't run fine because my script is:
> >
> > ...
> > system "java program_java";
> > ...
> >
> > How can I do Apache to run java programs?
>
> Not like that. Not, in fact, using Perl at all.
Why not? It just looks like "java" isn't in the CGI process's $PATH...
Since the OP's script runs from the command line but not the browser,
I'd recommend the troubleshooting links in the FAQ.
% perldoc -q 500
--
Steve
------------------------------
Date: 29 Oct 2003 08:42:19 -0800
From: opencityproject@yahoo.com (dave the spazz)
Subject: job: perl script for authorize.net AIM (advanced integration method)
Message-Id: <27c6f057.0310290842.7027eef4@posting.google.com>
MUST BE NEW YORK BASED
we need someone to write a perl script for us as we move from SIM to
AIM using authorize.net
if you have experience with this please email me asap. thanks!
------------------------------
Date: 29 Oct 2003 09:20:27 -0800
From: wherrera@lynxview.com (Bill)
Subject: Re: multiline regular expression, is it possible?
Message-Id: <239ce42f.0310290920.6b05714@posting.google.com>
Ben Morrow <usenet@morrow.me.uk> wrote in message news:<bno022$71s$1@wisteria.csv.warwick.ac.uk>...
> #!/usr/bin/perl -l
>
> use warnings;
> use strict;
>
> my $myregexp = <<RE;
> <tr><td>
> id: (\\d{5}[AX])
> <\\/td><\\/tr>
> RE
>
> my $results = <<RES;
> <table>
> <tr><td>
> id: 45434X
> </td></tr>
> <tr><td>
> id: 95434A
> </td></tr>
> </table>
> RES
>
> print join ", ", $results =~ /$myregexp/g;
>
> __END__
>
> Worksforme.
Is the space between id: and \d accounted for here? Is that version
specific and does it matter in PHP?
------------------------------
Date: Wed, 29 Oct 2003 17:39:55 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: multiline regular expression, is it possible?
Message-Id: <bnou1b$k9a$2@wisteria.csv.warwick.ac.uk>
wherrera@lynxview.com (Bill) wrote:
> Ben Morrow <usenet@morrow.me.uk> wrote in message
> news:<bno022$71s$1@wisteria.csv.warwick.ac.uk>...
> > my $myregexp = <<RE;
> > <tr><td>
> > id: (\\d{5}[AX])
> > <\\/td><\\/tr>
> > RE
>
> Is the space between id: and \d accounted for here?
If you mean 'is it required to be there for the regex to match' then,
since I didn't use the /x switch, yes, it is.
> Is that version specific and does it matter in PHP?
It is not specific to a particular version of Perl[1]. With regard to
PHP, I suggest you consult the docs for libpcre.
Ben
[1] Leaving aside Perl6 for the moment... :)
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
Date: Wed, 29 Oct 2003 11:22:46 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Roy Johnson <rjohnson@shell.com>
Subject: Re: Resetting //g
Message-Id: <Pine.SGI.3.96.1031029111653.1055270A-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On 29 Oct 2003, Roy Johnson wrote:
>If you short-circuit out of a global pattern match like so:
> for (1..$n) {
> $str =~ /($pat)/g;
> $NthMatch = $1;
> }
>where there are more than $n matches, the next time you do
> $str =~ /($pat)/g;
>even if it's in a completely different block of code, the matching is
>going to pick up where it left off. Is there a way to reset it, short
>of whiling away the rest of the matches? (I tried several arguments
>for the reset function.)
You can set pos($str) to undef.
for (1 .. $n) {
$str =~ /($pat)/g;
$last = $1;
}
undef pos($str);
The /g flag makes the regex start looking at pos($str) next time; setting
it to undef makes it start looking at the beginning of the string again.
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Wed, 29 Oct 2003 16:26:32 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Singleton process
Message-Id: <bnopno$7e7$1@plover.com>
In article <bnm7vm$eel$2@wisteria.csv.warwick.ac.uk>,
Ben Morrow <usenet@morrow.me.uk> wrote:
>
>tassilo.parseval@post.rwth-aachen.de wrote:
>> Also sprach Roy Johnson:
>>
>> > I've got a program that I want to be the only instance of itself
>> > running at any given time. What *should* I be doing, for maximum
>> > reliability on both Unix and Windows?
>>
>> Locking, I guess. Let the program create a lockfile at the beginning:
>>
>> use Fcntl;
>>
>> sysopen LOCK, "/tmp/prog.lock", O_CREAT|O_EXCL or
>> exit 1;
>>
>> ...
>>
>> END { unlink "/tmp/prog.lock" }
>>
>> This should be portable between UNIX and Windows.
>
>What if the process is killed and leaves a stale lockfile around?
Can I suggest the following delightful and foolproof solution to this
problem?
http://perl.plover.com/yak/flock/samples/slide006.html
The full talk on this topic is available from
http://perl.plover.com/yak/flock/
------------------------------
Date: Wed, 29 Oct 2003 16:55:39 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Singleton process
Message-Id: <bnoreb$j8o$3@wisteria.csv.warwick.ac.uk>
mjd@plover.com (Mark Jason Dominus) wrote:
> In article <bnm7vm$eel$2@wisteria.csv.warwick.ac.uk>,
> Ben Morrow <usenet@morrow.me.uk> wrote:
> >
> >tassilo.parseval@post.rwth-aachen.de wrote:
> >> Also sprach Roy Johnson:
> >>
> >> > I've got a program that I want to be the only instance of itself
> >> > running at any given time. What *should* I be doing, for maximum
> >> > reliability on both Unix and Windows?
> >>
> >What if the process is killed and leaves a stale lockfile around?
>
> Can I suggest the following delightful and foolproof solution to this
> problem?
>
> http://perl.plover.com/yak/flock/samples/slide006.html
Nice, as usual :).
The problem of Win32 failing to break locks when a process is killed
(and I believe sometimes even failing to break them across reboots) is
of course not a Perl problem.
Ben
--
Although few may originate a policy, we are all able to judge it.
- Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: 29 Oct 2003 09:51:05 -0800
From: rschurchill@freenet.co.uk (Richard)
Subject: tie problem
Message-Id: <e74c9c5c.0310290951.39a0db56@posting.google.com>
I am writing a script which accesses a DBM file using SDBM. The
program works but throws out a warning of: -
Argument "O_RDWR" isn't numeric in null operation
I've included Fcntl but that doesn't solve the problem. Does anyone
know why this is happening?
Thanks
Richard
use SDBM_File;
use Fcntl;
tie (%DB, 'SDBM_File', "fund.dbm",O_RDWR, 0644) or die "Couldn't find
file\n";
foreach $fund (keys %DB) {
print $fund;
}
untie %DB;
------------------------------
Date: Wed, 29 Oct 2003 18:00:37 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: tie problem
Message-Id: <bnov85$kqk$1@wisteria.csv.warwick.ac.uk>
rschurchill@freenet.co.uk (Richard) wrote:
> I am writing a script which accesses a DBM file using SDBM. The
> program works but throws out a warning of: -
>
> Argument "O_RDWR" isn't numeric in null operation
>
> I've included Fcntl but that doesn't solve the problem. Does anyone
> know why this is happening?
Try again like this:
#!/usr/bin/perl
use warnings;
use strict;
> use SDBM_File;
> use Fcntl;
>
> tie (%DB, 'SDBM_File', "fund.dbm",O_RDWR, 0644) or die "Couldn't find
> file\n";
Don't put \n on the end: it suppresses useful information about where
the error occurred.
Do include $!.
SDMB_File suggests you should usually use 0666 for the mode, as it is
modified by the umask.
> foreach $fund (keys %DB) {
> print $fund;
> }
>
> untie %DB;
You should probably use
untie %DB or die "failed to untie: $!";
here, as well.
If you get an error about O_RDWR, post again. 'use Fcntl' ought to
define it.
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: 29 Oct 2003 08:36:05 -0800
From: tony.walker@dhl.com (Tony Walker)
Subject: What am I doing wrong?!
Message-Id: <72461e59.0310290836.4f06d55f@posting.google.com>
Hi Guys,
OK, what I'm doing is a basic search of a logfile for specific
strings. At present I have this working fine by manually creating an
array and foreaching it..
However, I now want to read these strings from a file and perform the
same actions as before but I'm hitting a problem. I slurp the file
into and array and it only ever finds ONE of the strings in the file,
not the other!!
Any help much appreciated..
Tony
p.s this is my first attempt at perl so it may not look great...
##
#!/opt/perl/bin/perl
open (ER,"ALL_errors") or die "$!";
my @entry = <ER>;
open (LOG,"all.log") or die "$!";
while (<LOG>){
my $CUR=$_;
for (my $i=0;$i<=$#entry;$i++) {
my $LINE = @entry[$i];
if ($CUR =~/$LINE/){
print $CUR;
}
}
}
####
------------------------------
Date: Wed, 29 Oct 2003 16:47:31 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: What am I doing wrong?!
Message-Id: <DaSnb.16477$%e3.11266@nwrddc03.gnilink.net>
Tony Walker wrote:
> OK, what I'm doing is a basic search of a logfile for specific
> strings. At present I have this working fine by manually creating an
> array and foreaching it..
> However, I now want to read these strings from a file and perform the
> same actions as before but I'm hitting a problem. I slurp the file
> into and array and it only ever finds ONE of the strings in the file,
> not the other!!
>
> Any help much appreciated..
>
> Tony
>
> p.s this is my first attempt at perl so it may not look great...
> ##
> #!/opt/perl/bin/perl
> open (ER,"ALL_errors") or die "$!";
> my @entry = <ER>;
I wager you forgot to chomp() here.
> open (LOG,"all.log") or die "$!";
> while (<LOG>){
> my $CUR=$_;
> for (my $i=0;$i<=$#entry;$i++) {
Och, that's C, not Perl:
for (my $i=0..@entry)
Or use just
for (@entry)
> my $LINE = @entry[$i];
> if ($CUR =~/$LINE/){
and then here
if ($CUR =~/$_/){
instead fo the two lines above
> print $CUR;
> }
> }
> }
> ####
------------------------------
Date: Wed, 29 Oct 2003 18:29:25 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: What am I doing wrong?!
Message-Id: <pan.2003.10.29.17.10.21.69312@aursand.no>
On Wed, 29 Oct 2003 08:36:05 -0800, Tony Walker wrote:
> #!/opt/perl/bin/perl
use strict;
use warnings;
use diagnostics;
> open (ER,"ALL_errors") or die "$!";
> my @entry = <ER>;
>
> open (LOG,"all.log") or die "$!";
> while (<LOG>){
> my $CUR=$_;
> for (my $i=0;$i<=$#entry;$i++) {
> my $LINE = @entry[$i];
> if ($CUR =~/$LINE/){
> print $CUR;
> }
> }
> }
Very C'ish, indeed. Let's do the same thing Perl'ish;
open( ER, 'ALL_errors' ) or die "Couldn't open file; $!\n";
my @entry = <ER>;
close( ER );
chomp( @entry );
open( LOG, 'all.log' ) or die "Couldn't open file; $!\n";
while my $cur ( <LOG> ) {
chomp( $cur );
foreach my $line ( @entry ) {
print $cur if ( $cur =~ /$line/ );
}
}
close( LOG );
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Wed, 29 Oct 2003 17:29:51 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: What am I doing wrong?!
Message-Id: <mbudash-671A7B.09295129102003@typhoon.sonic.net>
In article <72461e59.0310290836.4f06d55f@posting.google.com>,
tony.walker@dhl.com (Tony Walker) wrote:
> Hi Guys,
>
> OK, what I'm doing is a basic search of a logfile for specific
> strings. At present I have this working fine by manually creating an
> array and foreaching it..
> However, I now want to read these strings from a file and perform the
> same actions as before but I'm hitting a problem. I slurp the file
> into and array and it only ever finds ONE of the strings in the file,
> not the other!!
>
> Any help much appreciated..
>
> Tony
>
> p.s this is my first attempt at perl so it may not look great...
> ##
> #!/opt/perl/bin/perl
> open (ER,"ALL_errors") or die "$!";
> my @entry = <ER>;
>
> open (LOG,"all.log") or die "$!";
> while (<LOG>){
> my $CUR=$_;
> for (my $i=0;$i<=$#entry;$i++) {
> my $LINE = @entry[$i];
> if ($CUR =~/$LINE/){
> print $CUR;
> }
> }
> }
> ####
####
open (ER,"ALL_errors") or die "$!";
my @entry = <ER>;
close (ER);
chomp @entry;
open (LOG,"all.log") or die "$!";
while (<LOG>){
foreach my $entry (@entry) {
print if /$entry/;
}
}
close (LOG);
####
hope this helps
--
Michael Budash
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 5726
***************************************