[19016] in Perl-Users-Digest
Perl-Users Digest, Issue: 1211 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 28 14:10:40 2001
Date: Thu, 28 Jun 2001 11:10:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <993751819-v10-i1211@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 28 Jun 2001 Volume: 10 Number: 1211
Today's topics:
Re: Overlapping regular expression results (Anno Siegel)
Re: Overlapping regular expression results (Greg Bacon)
Re: Overlapping regular expression results nobull@mail.com
Re: Overlapping regular expression results <ren@tivoli.com>
Re: Overlapping regular expression results (Anno Siegel)
Re: Overlapping regular expression results nobull@mail.com
Re: passing variables the 'right' way <mjcarman@home.com>
Re: passing variables the 'right' way <joe+usenet@sunstarsys.com>
pattern matching error <notell@hate_spam.com>
Re: pattern matching error (Anno Siegel)
Perl 6: -> vs . <jim@perlservices.com>
Re: PERL and CGI under NT IIS nobull@mail.com
Perl Chmod vs. System Chmod, your thoughts? (CPERL520335)
Re: Perl Chmod vs. System Chmod, your thoughts? <tony_curtis32@yahoo.com>
Perl Conference: European Yet Another Perl Conference 2 <nospam@wendy.org>
Perl with MS Access <tambaa@no.spam.yahoo.com>
PERL won't load a file on Windows, but it will on UNIX <joseph.slater@wright.edu>
Re: PERL won't load a file on Windows, but it will on U <mbudash@sonic.net>
Re: PERL won't load a file on Windows, but it will on U <ren@tivoli.com>
Re: PostgreSQL/Perl error (Lisa Koma)
problems with mod_perl <snefski@hotmail.com>
Re: problems with mod_perl <SEE_MY_SIG@nospam.demon.co.uk>
Re: problems with mod_perl <snefski@hotmail.com>
Re: problems with mod_perl <randy@theoryx5.uwinnipeg.ca>
Re: Scanning a file in CGI <jim@perlservices.com>
Re: Scanning a file in CGI (Anno Siegel)
Search script: passing information between programs? (Alex)
Re: seek or sysseek? <davsoming@lineone.net>
Re: system("cat ..) vs. print (Villy Kruse)
Re: system("cat ..) vs. print (Tad McClellan)
What kind of object is an old-fashioned DBM? <amittai@amittai.com>
Re: What kind of object is an old-fashioned DBM? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Jun 2001 13:35:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Overlapping regular expression results
Message-Id: <9hfbqj$8aa$1@mamenchi.zrz.TU-Berlin.DE>
According to Bernard El-Hagin <bernard.el-hagin@lido-tech.net>:
> On Thu, 28 Jun 2001 11:57:08 +0100, David Pratt <pratt@biop.ox.ac.uk> wrote:
> >Hi,
> >
> >I'm trying to get _all_ the matches to a regular expression in my string
> >including the 'overlapping ones'. For example :
> >
> >If my string is
> >
> >$seq = 'attctctctcggata'
> >
> >and my reg-ex is /.ctctc/
> >
> >i'd want to get both examples of tctctc, i.e. _tctctc_tc and tc_tctctc_.
> >the _'s indicating the found strings.
>
> push @found, $1 while $seq =~ /(?=(.ctctc))/g;
Ah, a lookaround solution. It even works with just /g in list context:
@found = $seq =~ /(?=($regex))/g;
I never thought of capturing matches inside non-capturing parentheses,
but of course there's no contradiction.
Anno
------------------------------
Date: Thu, 28 Jun 2001 13:51:06 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Overlapping regular expression results
Message-Id: <tjmdia5kblnmd0@corp.supernews.com>
In article <slrn9jm646.3b3.rgarciasuarez@rafael.kazibao.net>,
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
: A probably better (but more complex, and less "flex-ible") approach is
: to implement a fast search algorithm that will return all places where
: the keyword "ctctc" is found in an input string without scanning it
: backwards. I remember that Aho, Sethi and Ullman describe such an
: algorithm in the Dragon Book, but I can't remember its name right now.
: I'm sure that several regulars here see what I mean.
Boyer-Moore? IIRC, the regular expression matcher and the index()
operator use Boyer-Moore.
Greg
--
You've got to understand their market has always been the Windows space,
where you're actually doing people a favor by charging them money for things,
because that's the only way to keep from confusing them.
-- Larry Wall on ActiveState
------------------------------
Date: 28 Jun 2001 17:44:15 +0100
From: nobull@mail.com
Subject: Re: Overlapping regular expression results
Message-Id: <u9bsn8zh9c.fsf@wcl-l.bham.ac.uk>
bernard.el-hagin@lido-tech.net (Bernard El-Hagin) writes:
> >$seq = 'attctctctcggata'
> >
> >and my reg-ex is /.ctctc/
> >
> >i'd want to get both examples of tctctc, i.e. _tctctc_tc and tc_tctctc_.
> >the _'s indicating the found strings.
>
> push @found, $1 while $seq =~ /(?=(.ctctc))/g;
OK, how come that works? By rights it should be an infinite loop.
Looks to me like as well as the visible value of pos() there's also a
hidden flag saying the last match was zero-width and that another zero
with match starting at pos() should be ignored. DWIM gone mad!
$_ = "abcdefghijk";
/^...(.)/g;
print "\$1=$1 pos=",pos,"\n";
/(?=(.))/g;
print "\$1=$1 pos=",pos,"\n";
/(?=(.))/g;
print "\$1=$1 pos=",pos,"\n";
/(.)/g;
print "\$1=$1 pos=",pos,"\n";
__END__
$1=d pos=4
$1=e pos=4
$1=f pos=5
$1=f pos=6
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 28 Jun 2001 09:48:33 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Overlapping regular expression results
Message-Id: <m3ofr8vewu.fsf@dhcp9-173.support.tivoli.com>
On 28 Jun 2001, nobull@mail.com wrote:
> David Pratt <pratt@biop.ox.ac.uk> writes:
>
>> If my string is
>>
>> $seq = 'attctctctcggata'
>>
>> and my reg-ex is /.ctctc/
>>
>> i'd want to get both examples of tctctc, i.e. _tctctc_tc and
>> tc_tctctc_. the _'s indicating the found strings.
>
> my @found;
> push @found => $1 while $seq =~ /(?=($regex))./g;
my @found = $seq =~ /(?=($regex))/g;
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 28 Jun 2001 17:36:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Overlapping regular expression results
Message-Id: <9hfpv1$et1$3@mamenchi.zrz.TU-Berlin.DE>
According to <nobull@mail.com>:
> bernard.el-hagin@lido-tech.net (Bernard El-Hagin) writes:
>
> > >$seq = 'attctctctcggata'
> > >
> > >and my reg-ex is /.ctctc/
> > >
> > >i'd want to get both examples of tctctc, i.e. _tctctc_tc and tc_tctctc_.
> > >the _'s indicating the found strings.
> >
> > push @found, $1 while $seq =~ /(?=(.ctctc))/g;
>
> OK, how come that works? By rights it should be an infinite loop.
>
> Looks to me like as well as the visible value of pos() there's also a
> hidden flag saying the last match was zero-width and that another zero
> with match starting at pos() should be ignored. DWIM gone mad!
[snip examples]
I think it's a common practice (if not a necessity) for a regex
engine to take care that a zero-width match doesn't match in the
same place again.
Anno
------------------------------
Date: 28 Jun 2001 18:27:03 +0100
From: nobull@mail.com
Subject: Re: Overlapping regular expression results
Message-Id: <u94rt0zfa0.fsf@wcl-l.bham.ac.uk>
Ren Maddox <ren@tivoli.com> writes:
> On 28 Jun 2001, nobull@mail.com wrote:
> > push @found => $1 while $seq =~ /(?=($regex))./g;
>
> my @found = $seq =~ /(?=($regex))/g;
I thought I remembered that as working in the past but when I tested
it (before I posted) it didn't. Guess I must have mis-typed it
because testing it again I find it works.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 28 Jun 2001 08:52:50 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: passing variables the 'right' way
Message-Id: <3B3B36B2.4371BE0@home.com>
Jakob Schmidt wrote:
>
> abigail@foad.org (Abigail) writes:
>
> > It looks like list assignment is generally faster than doing
> > all the separate lookups and scalar assignment.
>
> Ok - it makes sense now, thanks.
>
> This also saves me, since my $x = shift; as an idiom is still silly
> then :-)
I wouldn't call it silly, I'd call it a sytle issue. I almost always
write my subs this way:
sub mysub {
my $alpha = shift;
my $beta = shift;
my $gamma = shift;
#...
}
For me, it's visually cleaner and makes maintenance easier. It's more
flexible too:
sub mysub {
my $alpha = shift;
my @beta = map {$_ + 1} split /:/, shift;
my $gamma = shift || 42;
#...
}
My perl wan't compiled with debugging, so I can't tell you what the byte
code is doing as Abigail did, but any real-world timing differences are
pretty negligable. If you're *that* concerned about speed, you shouldn't
be using Perl.
It's fine to use "my ($alpha, $beta, $gamma) = @_" if you prefer it, but
calling it a performance enhancement is nothing more than misguided
microoptimization.
-mjc
------------------------------
Date: 28 Jun 2001 13:58:28 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: passing variables the 'right' way
Message-Id: <m31yo4qyez.fsf@mumonkan.sunstarsys.com>
Michael Carman <mjcarman@home.com> writes:
> My perl wan't compiled with debugging, so I can't tell you what the byte
> code is doing as Abigail did,
% perl -Dt -we 'sub f {my $x = shift} f' > /tmp/shift
% perl -Dt -we 'sub f {my ($x) = @_ } f' > /tmp/aasign
% diff -u /tmp/shift /tmp/aasign
--- /tmp/aasign Thu Jun 28 10:46:05 2001
+++ /tmp/shift Thu Jun 28 10:46:17 2001
@@ -7,10 +7,11 @@
(-e:1) gv(main::f)
(-e:1) entersub
(-e:1) nextstate
-(-e:1) pushmark
(-e:1) gv(main::_)
(-e:1) rv2av
-(-e:1) pushmark
+(-e:1) shift
(-e:1) padsv[1]
-(-e:1) aassign
+(-e:1) sassign
(-e:1) leavesub
(-e:1) leave
%
The difference in scaling over multiple args is that aasign only needs
additional padsv calls (for building the lexicals), whereas shift requires
(-e:1) gv(main::_)
(-e:1) rv2av
(-e:1) shift
(-e:1) padsv[1]
(-e:1) sassign
(-e:1) nextstate
for each assignment (this is similar to the "my $x = $_[0]" analysis
Abigail gave earlier).
> but any real-world timing differences are pretty negligable. If you're
> *that* concerned about speed, you shouldn't be using Perl.
>
> It's fine to use "my ($alpha, $beta, $gamma) = @_" if you prefer it, but
> calling it a performance enhancement is nothing more than misguided
> microoptimization.
For three args on my AMD 233 linux box, the largest difference between
them is about 2 microseconds per call, while the amount of overhead for
using a subroutine instead of a bare block is about 5 microseconds.
If such differences really matter, you probably shouldn't be "passing
variables" in the first place :-)
--
Joe Schaefer "I don't give a damn for a man that can only spell a word one
way."
--Mark Twain
------------------------------
Date: Thu, 28 Jun 2001 11:24:26 -0400
From: "MrEye" <notell@hate_spam.com>
Subject: pattern matching error
Message-Id: <9hfi4p$3ml$1@trsvr.tr.unisys.com>
Deos anyone know what is wrong with the code below? It worked with perl
5.005. I just upgraded to perl5.6. Is this a change or a bug?
error:
Missing braces on \N{} at process_diff.pl line 18, within pattern
drocess_diff line 18:
if (/^\s*[\$]\NOPREFIX/i) {
print "#INFO: Found NOPREFIX\n";
$prefix="";
$PREFIX="_NONE_";
nextline;
}
------------------------------
Date: 28 Jun 2001 16:22:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: pattern matching error
Message-Id: <9hflko$et1$1@mamenchi.zrz.TU-Berlin.DE>
According to MrEye <notell@hate_spam.com>:
> Deos anyone know what is wrong with the code below? It worked with perl
> 5.005. I just upgraded to perl5.6. Is this a change or a bug?
>
> error:
>
> Missing braces on \N{} at process_diff.pl line 18, within pattern
>
>
>
> drocess_diff line 18:
>
> if (/^\s*[\$]\NOPREFIX/i) {
^
here
The backslash is probably a typo. Since "\N" had no specific meaning
before 5.6, it was politely ignored (but was a bug anyway). Now,
"\N" has a meaning, and it expects something in {} to follow. So
it's a syntax error now.
Anno
------------------------------
Date: Thu, 28 Jun 2001 13:32:08 -0400
From: "Jim Melanson" <jim@perlservices.com>
Subject: Perl 6: -> vs .
Message-Id: <5TJ_6.7534$9m1.90143@localhost>
The traffic lights article:
http://www.perl.com/pub/2001/05/22/trafficlights.html#1
by Michael Schwern says that in Perl 6 the -> operator for method calls is
going to be replaced by the period (.). (See the footnotes).
Does anyone know if they are keeping backwards compatability or we going to
have to re-write all our modules and scripts for Perl 6??
Best Wishes,
Jim
--
President & Founder
Perl Services
www.perlservices.net
Director of Programming,
Robinson Internet Solutions
www.robinsoninternet.com
Founder of Charity Ware, 1997
www.charityware.ws
International Who's Who
of Information Technology
Member since 2000
jim@perlservices.net
jim@robinsoninternet.com
jim@charityware.ws
ICQ# 116084898
1-877-751-5900 North America
1-760-249-3676 International
1-208-694-1613 FAX
"Do or do not. There is no try."
--- Yoda
===========================
"To do is to be" - Descartes
"To be is to do" - Voltaire
"Do be do be do" - Sinatra
------------------------------
Date: 28 Jun 2001 17:54:05 +0100
From: nobull@mail.com
Subject: Re: PERL and CGI under NT IIS
Message-Id: <u98ziczh73.fsf@wcl-l.bham.ac.uk>
David <nospamdd0001@yahoo.com> writes:
> Subject: PERL and CGI under NT IIS
> $testData = "testdata.dat";
> open (TESTDATA, $testData) or &crash ("Can't open $testData:
> $OS_ERROR");
> testdata.dat is in the same folder and contains:
The GCI standard makes no stipulation about the setting of the current
working directory when a CGI script is invoked. (IHMO this was a
mistake).
Most Unix web servers will set the CWD to the directory containing the
script anyhow. (IMNSHO this should be stipulated by CGI).
IIS runs CGI scripts with a different CWD (server root IIRC). (IMNHSO
this was bloody-mindedness).
This, of course, has nothing to do with Perl.
> now is the time for all good men to get their PERL scripts running
"Good men" know that it's "Perl" not "PERL".
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 28 Jun 2001 15:00:44 GMT
From: cperl520335@aol.com (CPERL520335)
Subject: Perl Chmod vs. System Chmod, your thoughts?
Message-Id: <20010628110044.10981.00001406@ng-ba1.aol.com>
I've been using perl's chmod function
chmod(0777, "variables.var");
but I've found that on some servers this wont work (e.g. Apache in the cgi-bin
where it wont let you open html files either)
I've noticed others using:-
system("site chmod 777 variables.var");
or
system("chmod 777 variables.var");
Does this work on all systems?
could I have something like:-
system("site chmod 777 variables.var") | system("chmod 777 variables.var") |
print "cant chmod";
Any body have experiences with this sort of thing?
------------------------------
Date: 28 Jun 2001 10:04:19 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Perl Chmod vs. System Chmod, your thoughts?
Message-Id: <87u210y7bg.fsf@limey.hpcc.uh.edu>
>> On 28 Jun 2001 15:00:44 GMT,
>> cperl520335@aol.com (CPERL520335) said:
> but I've found that on some servers this wont work
> (e.g. Apache in the cgi-bin where it wont let you open
> html files either)
That's a web-server / CGI permissions problem, it would
crop up in any language you're writing in.
> system("site chmod 777 variables.var"); or
That one's for FTP.
> system("chmod 777 variables.var");
That works the same as perl's internal chmod (but forces
an external shell to do so and is non-portable).
> Any body have experiences with this sort of thing?
This may enlighten a bit:
http://www.boutell.com/openfaq/cgi/8.html
hth
t
--
Somebody light this monkey. AAAAGGGHHHH!! Bad monkey!
------------------------------
Date: Thu, 28 Jun 2001 15:50:41 GMT
From: WvDijk <nospam@wendy.org>
Subject: Perl Conference: European Yet Another Perl Conference 2001
Message-Id: <3B3B5249.18AA8496@wendy.org>
European Yet Another Perl Conference
YAPC::Europe-2.0.01
http://www.yapc.org/Europe/
Thursday-Saturday, August 2-4, 2001 at the Hogeschool Holland,
Amsterdam, the Netherlands.
Yet Another Perl Conference (YAPC) is an inexpensive (99 EURO)
conference for Perl users and developers. The programme is a mix of
tutorials and technical talks, some of which focus on this year's theme,
'Security.'
Registration is now open at
<http://www.yapc.org/Europe/registration.html>!
We encourage you to register early as there is limited space. People
registering before 11 July will receive a conference t-shirt.
For up-to-date information, refer to the web site or join the mailing
list by sending mail to <majordomo@lists.dircon.co.uk> with 'subscribe
yapc-europe' in the email body.
A hack session will be held for CPANTS (CPAN Testing Service) several
days before and after the conference. For more information subscribe to
<cpants-devel@lists.sourceforge.net> via
<http://lists.sourceforge.net/lists/listinfo/cpants-devel>.
We look forward to seeing you at YAPC::Europe-2.0.01!
------------------------------
Date: Thu, 28 Jun 2001 11:08:57 -0500
From: "T.H." <tambaa@no.spam.yahoo.com>
Subject: Perl with MS Access
Message-Id: <9hfkfm$qo2$1@tilde.csc.ti.com>
Anyone know of a good web resource with sample Perl scripts on manipulating
MS Access databases?
TIA
T.H.
------------------------------
Date: Thu, 28 Jun 2001 11:56:55 -0400
From: "Joseph C. Slater" <joseph.slater@wright.edu>
Subject: PERL won't load a file on Windows, but it will on UNIX
Message-Id: <joseph.slater-095A31.11565528062001@mercury.wright.edu>
The following script won't work on Windows, but it will on UNIX and
MacOS. The text file is never loaded into the variable. Isn't PERL
supposed to be platform independent? The line "print(@textfile);"
returns nothing. I'm using Active PERL on wind '98.
Thanks,
Joe
#!/usr/local/bin/perl
{
foreach $inFileName (@ARGV) {
open(INTEXTFILE, $inFileName);
open(OUTTEXTFILE, ">". $inFileName . ".converted");
print "Opened\n";
@textFile = <INTEXTFILE>;
print "Converted\n";
print(@textfile);
print "textfile\n";
foreach $textline (@textFile) {
$textline =~ s/\x0a//g;
print $textline;
};
print OUTTEXTFILE @textFile;
close (INTEXTFILE);
close (OUTTEXTFILE);
rename($inFileName,$inFileName . ".dos");
rename($inFileName . ".converted",$inFileName);
}
}
------------------------------
Date: Thu, 28 Jun 2001 10:09:52 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: PERL won't load a file on Windows, but it will on UNIX
Message-Id: <mbudash-007F84.10095228062001@news.pacbell.net>
In article <joseph.slater-095A31.11565528062001@mercury.wright.edu>,
"Joseph C. Slater" <joseph.slater@wright.edu> wrote:
> The following script won't work on Windows, but it will on UNIX and
> MacOS. The text file is never loaded into the variable. Isn't PERL
> supposed to be platform independent? The line "print(@textfile);"
> returns nothing. I'm using Active PERL on wind '98.
>
> Thanks,
> Joe
>
> #!/usr/local/bin/perl
> {
> foreach $inFileName (@ARGV) {
> open(INTEXTFILE, $inFileName);
> open(OUTTEXTFILE, ">". $inFileName . ".converted");
> print "Opened\n";
>
> @textFile = <INTEXTFILE>;
> print "Converted\n";
>
> print(@textfile);
> print "textfile\n";
[snip]
i'll bet a dollar to a donut that if you did 'the right thing':
open(INTEXTFILE, $inFileName)
|| die("Can't open $inFileName: $!");
open(OUTTEXTFILE, ">$inFileName.converted")
|| die("Can't create $inFileName.converted: $!");
you'd see what was wrong... yes perl is cross-platform (mostly), but
your code needs to be robust...
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 28 Jun 2001 11:30:51 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: PERL won't load a file on Windows, but it will on UNIX
Message-Id: <m3els4va6c.fsf@dhcp9-173.support.tivoli.com>
On Thu, 28 Jun 2001, joseph.slater@wright.edu wrote:
> The following script won't work on Windows, but it will on UNIX and
> MacOS. The text file is never loaded into the variable. Isn't PERL
> supposed to be platform independent? The line "print(@textfile);"
> returns nothing. I'm using Active PERL on wind '98.
>
> Thanks,
> Joe
>
> #!/usr/local/bin/perl
> {
> foreach $inFileName (@ARGV) {
> open(INTEXTFILE, $inFileName);
> open(OUTTEXTFILE, ">". $inFileName . ".converted");
> print "Opened\n";
>
> @textFile = <INTEXTFILE>;
> print "Converted\n";
>
> print(@textfile);
Case matters. @textfile and @textFile are different.
> print "textfile\n";
>
> foreach $textline (@textFile) {
> $textline =~ s/\x0a//g;
> print $textline;
>
> };
>
> print OUTTEXTFILE @textFile;
> close (INTEXTFILE);
> close (OUTTEXTFILE);
> rename($inFileName,$inFileName . ".dos");
> rename($inFileName . ".converted",$inFileName);
>
> }
> }
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 28 Jun 2001 06:17:42 -0700
From: zsh99@yahoo.com (Lisa Koma)
Subject: Re: PostgreSQL/Perl error
Message-Id: <d011d382.0106280517.109bd830@posting.google.com>
Thanks for the input:
I also get the following error. I can't explain it , ..really.
Sometime I get the error I posted earlier and other times the
following error.
Had to create DBD::Pg::dr::imp_data_size unexpectedly at
/source/perl5.005_03/lib/site_perl/5.005/sun4-solaris/DBI.pm line 657.
Use of uninitialized value at
/source/perl5.005_03/lib/site_perl/5.005/sun4-solaris/DBI.pm line 657.
Had to create DBD::Pg::db::imp_data_size unexpectedly at
/source/perl5.005_03/lib/site_perl/5.005/sun4-solaris/DBI.pm line 657.
Use of uninitialized value at
/source/perl5.005_03/lib/site_perl/5.005/sun4-solaris/DBI.pm line 657.
[Thu Jun 28 09:11:14 2001] [error] Undefined subroutine
&DBD::Pg::db::_login called at
/source/perl5.005_03/lib/site_perl/5.005/sun4-solaris/DBD/Pg.pm line
91.
(in cleanup) Driver has not implemented DESTROY for
DBI::db=HASH(0x2d2214) at
/source/perl5.005_03/lib/site_perl/5.005/sun4-solaris/Apache/Registry.pm
line 144
------------------------------
Date: Thu, 28 Jun 2001 15:05:56 +0200
From: S.E.Franke <snefski@hotmail.com>
Subject: problems with mod_perl
Message-Id: <MPG.15a54a233b37b335989685@news.cistron.nl>
Hi,...
I want to use mod_perl, but I couldn't find a appropriate newsgroup for
my problem, so I'll try it here ;-)
I have configured Apache and the mod_perl is working ok.I have seen a lot
of examples on the net, but I'm stuck here with a problem.
My script uses a Logger (Logger.pm) object, $lv_Logger.
I use sigHandlers in my script, and in the sub that handles the
sighandlers, I use the logger object.
The problems are with the logger object in the sub:
Variable $lv_Logger will not stay shared .........
how can I solve this problem???
Sven Franke.
Here is an example of my code:
#!/usr/bin/perl -w
use strict;
use Logger::HiRes;
my $lv_Logger = new Logger::HiRes (with some parameters...);
# Set signal handlers
$SIG{ALRM} = \$sigHandler;
alarm(5);
# processing data..........(cutted)
# sigHandler sub
sub sigHandler {
my $pm_Sig;
$lv_Logger->logError("Caught signal: $pm_Sig",{});
Apache::exit; # replacement for just exit in 'normal' perl
}
------------------------------
Date: Thu, 28 Jun 2001 14:43:18 +0100
From: James Taylor <SEE_MY_SIG@nospam.demon.co.uk>
Subject: Re: problems with mod_perl
Message-Id: <ant281318345fNdQ@oakseed.demon.co.uk>
In article <MPG.15a54a233b37b335989685@news.cistron.nl>,
S.E.Franke <snefski@hotmail.com> wrote:
>
> Here is an example of my code:
>
[snip]
>
> # Set signal handlers
> $SIG{ALRM} = \$sigHandler;
Should that be \&sigHandler; ?
--
James Taylor <james (at) oakseed demon co uk>
Based in Southam, Cheltenham, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Thu, 28 Jun 2001 16:06:37 +0200
From: S.E.Franke <snefski@hotmail.com>
Subject: Re: problems with mod_perl
Message-Id: <MPG.15a55853dbd9acbe989686@news.cistron.nl>
In article <ant281318345fNdQ@oakseed.demon.co.uk>,
SEE_MY_SIG@nospam.demon.co.uk says...
> In article <MPG.15a54a233b37b335989685@news.cistron.nl>,
> S.E.Franke <snefski@hotmail.com> wrote:
> >
> > Here is an example of my code:
> >
> [snip]
> >
> > # Set signal handlers
> > $SIG{ALRM} = \$sigHandler;
>
> Should that be \&sigHandler; ?
>
>
yes...sorry........
------------------------------
Date: 28 Jun 2001 17:22:28 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: problems with mod_perl
Message-Id: <9hfp4k$l9k$1@canopus.cc.umanitoba.ca>
In comp.lang.perl.misc, S.E.Franke <snefski@hotmail.com> wrote:
> I want to use mod_perl, but I couldn't find a appropriate newsgroup for
> my problem, so I'll try it here ;-)
There's a mailing list for mod_perl - see http://perl.apache.org/
for subscription details.
> I have configured Apache and the mod_perl is working ok.I have seen a lot
> of examples on the net, but I'm stuck here with a problem.
> My script uses a Logger (Logger.pm) object, $lv_Logger.
> I use sigHandlers in my script, and in the sub that handles the
> sighandlers, I use the logger object.
> The problems are with the logger object in the sub:
> Variable $lv_Logger will not stay shared .........
[ ... ]
The mod_perl guide at http://perl.apache.org/guide/ has a discussion
of the "variable will not stayed shared ..." problem.
best regards,
randy kobes
------------------------------
Date: Thu, 28 Jun 2001 13:25:02 -0400
From: "Jim Melanson" <jim@perlservices.com>
Subject: Re: Scanning a file in CGI
Message-Id: <rMJ_6.7533$9m1.89892@localhost>
Hi,
Change this:
while(<I>)
{
($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/);
to this:
my @contents = <I>;
close I;
chomp @contents;
for(my $a = 0; $a <= $#contents; $a++) {
($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/,
$contents[$a]);
This will loop through the the file in order. If you don't care if it gets
the exact order, this is faster:
foreach(@contents) {
($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/, $_);
Jim
President & Founder
Perl Services
www.perlservices.net
Director of Programming,
Robinson Internet Solutions
www.robinsoninternet.com
Founder of Charity Ware, 1997
www.charityware.ws
International Who's Who
of Information Technology
Member since 2000
jim@perlservices.net
jim@robinsoninternet.com
jim@charityware.ws
ICQ# 116084898
1-877-751-5900 North America
1-760-249-3676 International
1-208-694-1613 FAX
"Do or do not. There is no try."
--- Yoda
===========================
"To do is to be" - Descartes
"To be is to do" - Voltaire
"Do be do be do" - Sinatra
"Danny Hendrickx" <daniel.hendrickx@alcatel.be> wrote in message
news:3B39A0E1.5837118E@alcatel.be...
> Hello,
>
> I try to write a CGI program that scans a file line by line and prints
> out the parts of the line in different variables in a table (parts are
> separated by '|' in the file to be scanned).
>
> I used the normal perl way of scanning through the file, but apparantly
> this doesn't work. All I get to see is the top row of my table, and no
> entries in the table.
>
> Can anyone tell me what I'm doing wrong. The program is below, and below
> it is the file I use for scanning.
>
> TIA
>
> #!/usr/local/bin/perl -w
>
> use strict;
>
> use CGI qw(:standard);
>
> my (
> $TITLE,
> $HEADER,
> $ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw,
> $entry,@entries
> );
>
> $TITLE = "SS31 Document Overview";
> $HEADER = "Parm documents";
>
> print header(),start_html($TITLE),h1($HEADER);
>
> print p("<center>h1($HEADER)</center>");
> if (param())
> {
> }
> else
> {
> print hr();
> open (I,"<s1docs.txt")||die "Cannot open s1docs.txt:$!";
> print p("<table BORDER>
> <tr>
> <td VALIGN=CENTER><b><font size+1>Title</font></b></td>
> <td VALIGN=CENTER><b><font size+1>Number</font></b></td>
> <td VALIGN=CENTER><b><font size+1>Internal
> Ref</font></b></td>
> <td VALIGN=CENTER><b><font size+1>Cataloged</font></b></td>
> </tr>");
>
> while(<I>) #<== this part does not work
> {
> ($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/);
>
> if ($area eq "PARM")
> {
> print p("<tr>
> <td VALIGN=CENTER><a
> href=\"$doclink\">$doctitle</a></td>
> <td VALIGN=CENTER><a href=\"$doclink\">$docnr</a></td>
> <td VALIGN=CENTER>$ref></td>
> <td VALIGN=CENTER>$catalog></td>
> </tr>");
> }
>
> }
> close I;
> print p("<tr>
> <td></td>
> <td></td>
> <td></td>
> </tr>
> </table>");
>
> print end_form(),hr();
> }
> print end_html;
>
> and the s1docs.txt file:
>
> 1|PARM|document 1|number 1|link 1|yes|key 1
> 2|MISC|doc 2|nr 2|lnk 2|no|key 2
> 3|PARM|doc 3|nr 6|lnk 3|no|key 3
>
> --
> Regards,
> ________________
> ________________________________________________\ /_____
> Feature Development Team Leader WR2A team 7 Services and SAD /
> SW-Engineering - Routing - VJ33 Hendrickx Danny
> phone : +32-3-240 3916 ALCATEL TELECOM
> fax : +32-3-240 9899 Fr.Wellesplein 1
> mailto:daniel.hendrickx@alcatel.be 2018 Antwerp Belgium
> ______________________________________________________\ /___________
> URL: http://www.se.bel.alcatel.be/CH_sector1/SS31/ \/
> *********************************************************************
> The early bird gets the worm, but the second mouse gets the cheese.
> *********************************************************************
------------------------------
Date: 28 Jun 2001 17:53:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Scanning a file in CGI
Message-Id: <9hfqv7$k43$1@mamenchi.zrz.TU-Berlin.DE>
[please don't top-post]
According to Jim Melanson <jim@perlservices.com>:
> Hi,
In your code below, you are promoting a number of misconceptions.
> Change this:
>
> while(<I>)
> {
> ($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/);
>
> to this:
>
> my @contents = <I>;
> close I;
> chomp @contents;
There is absolutely *no* advantage in reading the whole file into
memory at once. Why do you propose it?
> for(my $a = 0; $a <= $#contents; $a++) {
There is no reason whatever to walk through the array using indexes.
See below.
> ($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/,
^
here...
...you might have noticed a severe bug. The "|" must be escaped in a
regex. Did you test your code?
> $contents[$a]);
>
>
> This will loop through the the file in order. If you don't care if it gets
> the exact order, this is faster:
What are you going on about? foreach processes the elements of an
array in order. You were probably thinking about a hash. Big
difference.
> foreach(@contents) {
> ($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/, $_);
[snip of huge sig & jeopardectomy]
Anno
------------------------------
Date: 28 Jun 2001 10:22:21 -0700
From: samara_biz@hotmail.com (Alex)
Subject: Search script: passing information between programs?
Message-Id: <c7d9d63c.0106280922.1ea3b58@posting.google.com>
Hello,
I am implementing a search script for a web site. I am not sure how to
pass results returned from my search script (which is just a program
on a Linux box) to a cgi script. I guess one way would be to write
them in a file and then read the file from the cgi script, but in this
case I would have to have a unique name for each file I'm writing to
avoid a race condition on files. (Or lock the file during read/write,
but that's more complicated). Is that the best way to do this? Can
someone maybe advise me on a better way of doing this?
Thanks a lot! I appreciate your help!
Alex
Here is some more details on what I am doing. I have a bunch of index
files containing keywords and their locations in the database. When a
user comes to the search webpage they can submit a keyword to a cgi
script, which then calls my perl search script with this keyword as a
parameter. The search script looks in the index files and finds
entries containing this keyword. Then I want this script to pass this
information back to the cgi script, so that the search results can be
formatted and outputted as a web page with results. Here's a diagram
of the relationship of the webpages and scripts:
------------
| SEARCH |
| WEB PAGE |
------------
| keyword
|
------------ -----------
| CGI | keyword -> | SEARCH |
| SCRIPT | <- results | SCRIPT |
------------ -----------
|
| parsed and formatted results
------------
| RESULTS |
| WEB PAGE |
------------
Is this scheme unnecessary complicated or am I on the right track? I
just want to make my search script generic, so that you don't have to
cut and paste a lot of the same code. That would also make it easy to
install it on any website.
Thanks a lot!
------------------------------
Date: Thu, 28 Jun 2001 17:21:39 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Re: seek or sysseek?
Message-Id: <tjmm0d882v4230@corp.supernews.co.uk>
Thanks :)
--
David Soming
'Just a head-banger- doing what I do best'
------------------------------
Date: 28 Jun 2001 15:47:23 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: system("cat ..) vs. print
Message-Id: <slrn9jmkc8.kul.vek@pharmnl.ohout.pharmapartners.nl>
On Thu, 28 Jun 2001 15:10:16 GMT,
John Imrie <john.imrie@pasport.press.net> wrote:
>
>The problem is that the system command runs the program in its own
>environment. This means that it has its own STDIN and SDTOUT. These are
>not captured by the web server. So the output from the comand is not
>redirected to the web browser but ends up in the greate bit bucket in the
>sky.
Can you explain this.
It is expected that a SGI program inherits the STDIN and STDOUT from
its parent process, and they will in turn be inherited by any children.
However, the output from the cat command may come out of sequence,
probably even before the HTTP headers are printed back to the browser.
On some systems, you can print up to 4 kb of data and nothing will be
written back to the browser until the CGI program terminates and flushes
its internal print buffer. When running the same program from the keyboard
the buffering will behave differently, and the result will therefore be
different.
Villy
------------------------------
Date: Thu, 28 Jun 2001 10:55:42 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: system("cat ..) vs. print
Message-Id: <slrn9jmhbe.m6u.tadmc@tadmc26.august.net>
John Imrie <john.imrie@pasport.press.net> wrote:
>
>
>>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
>
>On 28/06/01, 13:17:31, Christoph Neubauer <christoph.neubauer@siemens.at>
>wrote regarding Re: system("cat ..) vs. print:
>
>
>> Armin Wenz wrote:
>
>> > Christoph Neubauer wrote:
>> > > What happens, if you try:
>> > > (system ("cat $cert_file") == 0) or (die "$!");
>> >
>> > It works as well - everything's fine
>> > Can you explain it ?
>> >
>
>> No, sorry.
>
>> CN
>
>The problem is that the system command runs the program in its own
>environment. This means that it has its own STDIN and SDTOUT.
And what are those filehandles connected to?
Whatever they are connected to in the perl that launched them.
>These are
>not captured by the web server.
If the perl output is going to the web server on STDOUT, then cat's
output will be going there too.
>So the output from the comand is not
>redirected to the web browser but ends up in the greate bit bucket in the
>sky.
No it doesn't.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 27 Jun 2001 14:23:58 +0200
From: "Amittai Aviram" <amittai@amittai.com>
Subject: What kind of object is an old-fashioned DBM?
Message-Id: <9hcjom$8lb$1@rznews2.rrze.uni-erlangen.de>
I was trying to change my scripts that had used dbmopen() and dbmclose() to
use tie() instead. Tie requires the name of an object. If you use, say,
DB_File, then you declare "use DB_File;" and put "DB_File" as the second
parameter (in quotation marks) -- after your file handle -- in the tie()
function. But what if you have been using the old-fashioned DBMs that are
created with dbmopen and dbmclose? (Yes, I have been checking the manual,
books, and online sources -- must have missed it somewhere.) Thanks!
Amittai Aviram
------------------------------
Date: 28 Jun 2001 13:51:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: What kind of object is an old-fashioned DBM?
Message-Id: <9hfcpg$8aa$2@mamenchi.zrz.TU-Berlin.DE>
According to Amittai Aviram <amittai@amittai.com>:
> I was trying to change my scripts that had used dbmopen() and dbmclose() to
> use tie() instead. Tie requires the name of an object. If you use, say,
^^^^^^
class
> DB_File, then you declare "use DB_File;" and put "DB_File" as the second
> parameter (in quotation marks) -- after your file handle -- in the tie()
> function. But what if you have been using the old-fashioned DBMs that are
> created with dbmopen and dbmclose? (Yes, I have been checking the manual,
> books, and online sources -- must have missed it somewhere.) Thanks!
What's the problem? You use whatever flavor of DB was used creating
them. If you don't know, under Unix the file command may help.
Anno
------------------------------
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 1211
***************************************