[24933] in Perl-Users-Digest
Perl-Users Digest, Issue: 7183 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 27 14:06:47 2004
Date: Mon, 27 Sep 2004 11:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 27 Sep 2004 Volume: 10 Number: 7183
Today's topics:
RE: (was: decode the form information) <dontmesswithme@got.it>
Re: (was: decode the form information) <mark.clements@kcl.ac.uk>
Re: (was: decode the form information) <dontmesswithme@got.it>
Re: (was: decode the form information) <noreply@gunnar.cc>
Re: (was: decode the form information) <perl&nntp@rhesa.com>
RE: (was: decode the form information) <tore@aursand.no>
accessing perl's internal hashing algorithm (rob)
Re: accessing perl's internal hashing algorithm <mark.clements@kcl.ac.uk>
Re: accessing perl's internal hashing algorithm <notvalid@email.com>
Re: Arrays : When does the memory get used ? ctcgag@hotmail.com
Re: Help with my brute force method ctcgag@hotmail.com
Mail filtering without procmail using webmail client (J Cardella)
Re: Mail filtering without procmail using webmail clien <mark.clements@kcl.ac.uk>
Re: path delimiter in windows platform("/" could change (Peter Scott)
Re: path delimiter in windows platform("/" could change (Peter Scott)
Re: path delimiter in windows platform("/" could change <1usa@llenroc.ude.invalid>
Re: perl dev kit - perlrt.dll <usa1@llenroc.ude.invalid>
Re: Precedence of exponentiation (hymie!)
Re: Precedence of exponentiation <jluis@agujero-negro.escomposlinux.org>
Re: Precedence of exponentiation ctcgag@hotmail.com
Re: Printing regex match <tadmc@augustmail.com>
Problem in getting results on browser ... (Karuna)
Re: Problem in getting results on browser ... <usa1@llenroc.ude.invalid>
Re: references to filehandle? <usa1@llenroc.ude.invalid>
Re: references to filehandle? <bik.mido@tiscalinet.it>
Re: references to filehandle? <usa1@llenroc.ude.invalid>
Re: references to filehandle? <bik.mido@tiscalinet.it>
Regular expression don't match sequence of characters (Big Tony)
Re: Regular expression don't match sequence of characte (Anno Siegel)
Re: Regular expression don't match sequence of characte <tadmc@augustmail.com>
Re: Using C::Scan : How to ignore #includes ? <nospam-abuse@ilyaz.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 27 Sep 2004 14:26:56 GMT
From: Larry <dontmesswithme@got.it>
Subject: RE: (was: decode the form information)
Message-Id: <dontmesswithme-5BE859.16234427092004@twister2.tin.it>
and what do you think about this?
[code]
sub get_form_data {
my $temp;
my $buffer;
my @data;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
foreach $temp (split(/&|=/,$buffer)) {
$temp =~ tr/+/ /;
$temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
$temp =~ s/[\r\n]/ /g;
push @data, $temp;
}
foreach $temp (split(/&|=/,$ENV{'QUERY_STRING'})) {
$temp =~ tr/+/ /;
$temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
$temp =~ s/[\r\n]/ /g;
push @data, $temp;
}
return @data;
}
local %form = &get_form_data;
print $form{'something');
[/code]
is it enough reliable? It sounds good to me!!!
------------------------------
Date: Mon, 27 Sep 2004 17:12:25 +0200
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: (was: decode the form information)
Message-Id: <41582dd9$1@news.kcl.ac.uk>
Larry wrote:
> and what do you think about this?
>
> [code]
>
> sub get_form_data {
<snip>
> is it enough reliable? It sounds good to me!!!
You've been advised to use the CGI module. If you intend to produce
production code, then there isn't really an excuse not to use it. If you
don't then you are going to cause yourself all sorts of problems. I
doubt if anyone is going to be willing to step through your attempt at
cgi parameter parsing and comment on it....
Mark
------------------------------
Date: Mon, 27 Sep 2004 16:07:36 GMT
From: Larry <dontmesswithme@got.it>
Subject: Re: (was: decode the form information)
Message-Id: <dontmesswithme-652282.18042327092004@twister1.tin.it>
sub get_form_data {
my ($buffer,@pairs,$pair,$name,$value);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
elsif ($ENV{'REQUEST_METHOD'} eq 'GET') {
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
}
else { die "Errore... metodo non consentito\n"; }
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;
}
}
this sounds even better!!!!!!!!!
------------------------------
Date: Mon, 27 Sep 2004 18:15:51 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: (was: decode the form information)
Message-Id: <2rqskvF1ckhvvU1@uni-berlin.de>
Larry wrote:
> and what do you think about this?
>
> [code]
>
> sub get_form_data {
> my $temp;
> my $buffer;
> my @data;
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> foreach $temp (split(/&|=/,$buffer)) {
> $temp =~ tr/+/ /;
> $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
> $temp =~ s/[\r\n]/ /g;
> push @data, $temp;
> }
> foreach $temp (split(/&|=/,$ENV{'QUERY_STRING'})) {
> $temp =~ tr/+/ /;
> $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
> $temp =~ s/[\r\n]/ /g;
> push @data, $temp;
> }
> return @data;
> }
>
> local %form = &get_form_data;
>
> print $form{'something');
>
> [/code]
>
> is it enough reliable? It sounds good to me!!!
As a general purpose function for parsing CGI form data? No.
The very fact that you feel a need to ask shows that you don't know
enough about CGI to write such a function. It's good that you want to
learn, but asking open CGI questions in this group is the wrong way.
Studying the CGI spec and the source of Perl modules for the purpose
are two good ways.
You really should stick with CGI.pm or any of the alternative modules
available such as CGI::Lite or CGI::Minimal, at least for the time being.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 27 Sep 2004 19:18:23 +0200
From: Rhesa Rozendaal <perl&nntp@rhesa.com>
Subject: Re: (was: decode the form information)
Message-Id: <41584b5c$0$78753$e4fe514c@news.xs4all.nl>
Larry wrote:
> sub get_form_data {
>
> my ($buffer,@pairs,$pair,$name,$value);
>
> if ($ENV{'REQUEST_METHOD'} eq 'POST') {
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> }
> elsif ($ENV{'REQUEST_METHOD'} eq 'GET') {
> $buffer = $ENV{'QUERY_STRING'};
> @pairs = split(/&/, $buffer);
> }
> else { die "Errore... metodo non consentito\n"; }
>
> 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;
> }
>
> }
>
> this sounds even better!!!!!!!!!
Very nice, but what if I'm going to submit a form that has a group of
checkboxes (each one with the same name), and I select more than one?
The GET Url would look like:
/script.pl?cb=1;cb=2
Ouch!
First of all, ";" is also a valid option separator. Secondly, you loose the
first cb value.
Use CGI.pm.
------------------------------
Date: Mon, 27 Sep 2004 19:46:47 +0200
From: Tore Aursand <tore@aursand.no>
Subject: RE: (was: decode the form information)
Message-Id: <pan.2004.09.27.17.46.47.26414@aursand.no>
On Mon, 27 Sep 2004 14:26:56 +0000, Larry wrote:
> and what do you think about this?
Horrible. It will break. Eventually.
> [code]
>
> sub get_form_data {
> my $temp;
> my $buffer;
> my @data;
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> foreach $temp (split(/&|=/,$buffer)) {
> $temp =~ tr/+/ /;
> $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
> $temp =~ s/[\r\n]/ /g;
> push @data, $temp;
> }
> foreach $temp (split(/&|=/,$ENV{'QUERY_STRING'})) {
> $temp =~ tr/+/ /;
> $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
> $temp =~ s/[\r\n]/ /g;
> push @data, $temp;
> }
> return @data;
> }
>
> local %form = &get_form_data;
>
> print $form{'something');
>
> [/code]
>
> is it enough reliable?
No.
> It sounds good to me!!!
It doesn't matter how it sounds, as long as it doesn't work. The code
above is better written as:
my $CGI = CGI->new();
print $CGI->param('something');
So. Use the CGI module. It's a reason why everyone else uses it.
--
Tore Aursand <tore@aursand.no>
"War is too serious a matter to entrust to military men." (Georges
Clemenceau)
------------------------------
Date: 27 Sep 2004 08:14:21 -0700
From: robert_parks@csgsystems.com (rob)
Subject: accessing perl's internal hashing algorithm
Message-Id: <9129c854.0409270714.45bbf876@posting.google.com>
Hi, I have a performance intensive script that needs to hash a lot of
strings. I am guessing that perl's internal hashing algorithm is
implemented at a low level, is optimized, etc. and I would like to
access it though my perl scripts. Does anyone know how to do this?
Thanks,
Rob
------------------------------
Date: Mon, 27 Sep 2004 17:36:46 +0200
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: accessing perl's internal hashing algorithm
Message-Id: <4158338f$1@news.kcl.ac.uk>
rob wrote:
> Hi, I have a performance intensive script that needs to hash a lot of
> strings. I am guessing that perl's internal hashing algorithm is
> implemented at a low level, is optimized, etc. and I would like to
> access it though my perl scripts. Does anyone know how to do this?
I wouldn't have thought that the algorithm would be suitable for general
purpose use, but I stand open to correction. The Digest::SHA1 and
Digest::MD5 modules, for example, are implemented via xs and not native
perl (though clearly this is not a guarantee of speed: the algorithm can
suck whatever the implementation), so if raw performance is your
requirement then you could do worse than starting with these. You could
always check out the perl source directly if you're stuck on using
perl's internal algorithm: hv.c?
Mark
------------------------------
Date: Mon, 27 Sep 2004 18:00:04 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: accessing perl's internal hashing algorithm
Message-Id: <EyY5d.20385$QJ3.3057@newssvr21.news.prodigy.com>
rob wrote:
> Hi, I have a performance intensive script that needs to hash a lot of
> strings. I am guessing that perl's internal hashing algorithm is
> implemented at a low level, is optimized, etc. and I would like to
> access it though my perl scripts. Does anyone know how to do this?
A lot of the performance hit is probably due to Perl dynamically
enlarging hashes. If I remember correctly, when you declare a hash, Perl
allocates a certain size for it. As you starting populating this hash,
and once the number of keys hashed to the same integer exceeds a certain
threshold, Perl doubles the size of the hash (implemented as an array in
C), and re-indexes the keys. This can cause a lot of performace delay in
the case of a large number of keys to be hashed, especially if this
needs to be done multiple times.
The solution is to preallocate a large enough hash, if you think you can
guess how many keys you will need:
keys %hash = 5000;
Perl will round that number to the next power of two.
All of this is explained in Srinivasan's "Advanced Perl Programming"
(the Panther).
--Ala
------------------------------
Date: 27 Sep 2004 16:38:53 GMT
From: ctcgag@hotmail.com
Subject: Re: Arrays : When does the memory get used ?
Message-Id: <20040927123853.806$2c@newsreader.com>
Abhinav <matrix_calling@yahoo.dot.com> wrote:
> Hi,
>
> Considering the following :
>
> use strict;
> use warnings;
>
> my @array = (100,200);
> $array[50000] = 300;
>
> How much space is actually used by the array? Is it only for 3 values
> ($array[0], [1], [50000]), or for *all* the intervening indices also ?
>
> if(defined $array[2000])
>
> returns false. Does this mean that the space is, in fact, not allocated
> unless explicitly used?
>
> man perldata yields no answer...any where else where I can look ?
You could actually run the above code (with a sleep; at the end, and using
several different values larger than 50,000) and ask your OS how much
memory perl was taking at each one.
On my system, it uses 7 bytes per entervening entry.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 27 Sep 2004 16:58:26 GMT
From: ctcgag@hotmail.com
Subject: Re: Help with my brute force method
Message-Id: <20040927125826.247$yO@newsreader.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Tad McClellan <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> > Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > > krakle <krakle@visto.com> wrote in comp.lang.perl.misc:
> >
> >
> > >> close the opened file when you are done.. :)
> > >
> > > Why?
> >
> >
> > I can't think of a compelling reason in the context of a file
> > opened for _input_, as in this thread.
> >
> > But I _always_ have an explicit close() because it cost me
> > six and a half hours of debugging once. [1]
> >
> > The short version of the story: open()ed temp file for write,
> > chose OUT as the filehandle, days later, hundreds of lines of code
> > later, open()ed temp file for read, chose IN as the filehandle.
> >
> > Bug: missing some output data near the end
> >
> > Solution: add "close OUT" after writing temp file (flush buffer).
>
> [horror snipped]
>
> Ah, you're right. When dealing with named file handles open for
> writing you do have a point. Those are program-wide, and who
> knows what might happen. I might even close a global read-handle.
>
> Otherwise, lexical file handles close themselves when they go out of
> scope. Together with the rule of making scopes as small as possible,
> that takes care of it most of the time.
However, the automatic closing does not die or warn upon failure.
If you open an actual file for reading, this probably isn't a problem,
but if you open a pipe command, it can be. Since one of the things I like
about perl the ready ability to change file opens into pipe opens, I am
careful to avoid situations where doing just that would create hard to find
bugs.
Xho
>
> Anno
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 27 Sep 2004 07:55:06 -0700
From: dronf@pobox.com (J Cardella)
Subject: Mail filtering without procmail using webmail client
Message-Id: <b9eabb98.0409270655.3c66e5a6@posting.google.com>
Greetings --
Is there any alternative to procmail available?
I ask because my web host provider provides webamil clients (Squirrel
Mail, Horde, NeoMail) but they do not allow procmail to run on their
servers (I assume security concerns, or worse yet support concerns).
What I want to do is simple mail routing (writing mail to files), and
I imagine I can re-route text mails and have them "delivered"
(written) to mail folders, but my concern is with attachments and mail
that's not fullt text based. I also have the problem of having the
mail client interpret each mail individually, and not as one long
appended file.
Any mail gurus out there who can help? Searching the newsgroup
archives for "webamil without procmail" yeilds nothing.
Thanks in advance,
Joel
------------------------------
Date: Mon, 27 Sep 2004 19:13:07 +0200
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: Mail filtering without procmail using webmail client
Message-Id: <41584a23$1@news.kcl.ac.uk>
J Cardella wrote:
> Greetings --
>
> Is there any alternative to procmail available?
<snip>
This has nothing to do with perl. However...
>
> Any mail gurus out there who can help? Searching the newsgroup
> archives for "webamil without procmail" yeilds nothing.
I'm not surprised...... However, there are a number of alternatives to
procmail. You can set up filters in Imp (which is what I assume you mean
by Horde), or there are a number of programs that will run on the server
eg sieve or maildrop, but plugging these into the MTA is dependent on
the MTA itself and the hosting policy.
Mark
------------------------------
Date: Mon, 27 Sep 2004 13:42:37 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: path delimiter in windows platform("/" could change to "\"?)
Message-Id: <hNU5d.545240$gE.234083@pd7tw3no>
In article <Xns957084A3D6E83asu1cornelledu@132.236.56.8>,
"A. Sinan Unur" <1usa@llenroc.ude.invalid> writes:
>peter@PSDT.com (Peter Scott) wrote in news:tTA5d.114117$%S.21618
>@pd7tw2no:
>
>> In article <41563101.225947687@130.133.1.4>,
>> Alont <end@dream.life> writes:
>>>there are possible to change the "/" to "\" in windows platform?
>>
>> use File::Spec; # Core module
>> $file = File::Spec->canonpath($file);
>>
>
>That is good advice. However,
>
>#! perl
>
>use strict;
>use warnings;
>
>use File::Finder;
>use File::Spec::Functions qw( catfile );
>
>my $dir = catfile 'c:', 'www', 'unur', 'htdocs';
>my @html = File::Finder->type('f')->name('*.html')->in($dir);
>
>print "$_\n" for (@html);
>
>__END__
>
>This script will output:
>
>C:\www\unur\htdocs/index.html
>C:\www\unur\htdocs/comp/anti-spam-howto.html
>C:\www\unur\htdocs/comp/c-examples.html
>C:\www\unur\htdocs/comp/index.html
>
>so, the OP would still be asking the same question.
My intended message was that the poster do something like:
$_ = File::Spec->canonpath($_) for @html;
before the penultimate line of your example above.
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: Mon, 27 Sep 2004 15:19:42 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: path delimiter in windows platform("/" could change to "\"?)
Message-Id: <icW5d.123487$%S.32350@pd7tw2no>
In article <hNU5d.545240$gE.234083@pd7tw3no>, I wrote:
>before the penultimate line of your example above.
s/penultimate/last/
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: 27 Sep 2004 15:47:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: path delimiter in windows platform("/" could change to "\"?)
Message-Id: <Xns957177F53AAF5asu1cornelledu@132.236.56.8>
peter@PSDT.com (Peter Scott) wrote in news:hNU5d.545240$gE.234083@pd7tw3no:
> My intended message was that the poster do something like:
>
> $_ = File::Spec->canonpath($_) for @html;
>
> before the penultimate line of your example above.
Oooops! Sorry, I misunderstood your post.
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: 27 Sep 2004 13:38:06 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: perl dev kit - perlrt.dll
Message-Id: <Xns95716234C9F60asu1cornelledu@132.236.56.8>
paulmasquelier@hotmail.com (Paul Masquelier) wrote in
news:c663070b.0409270415.6b7c851b@posting.google.com:
> Hello,
>
> I am trying out perldevkit from activestate.
> When converting perl modules to dotnet assemblies, apparently some
> dll's are required when you put these assemblies on a pc without perl
>: perl58.dll, perlnh.dll and perlrt.dll. I cannot find perlrt.dll !
> Does anyone know where I can find this dll ??
Why not ask ActiveState?
Sinan.
------------------------------
Date: Mon, 27 Sep 2004 14:29:16 -0000
From: hymie@lactose.smart.net (hymie!)
Subject: Re: Precedence of exponentiation
Message-Id: <10lg8tspu89pj17@corp.supernews.com>
In our last episode, the evil Dr. Lacto had captured our hero,
David Frauzel <nemo@weathersong.net>, who said:
>Am I really in the minority in thinking that -2**4 should mean (-2)**4?
Well.. considering (-2)**4 == 2**4 , I would say that the answer is "Yes,
most people would apply the unary-minus after the exponentiation."
I've got a high-school-math teacher in the house. I'll see what she
thinks tonight.
hymie! http://www.smart.net/~hymowitz hymie@lactose.smart.net
===============================================================================
------------------------------
Date: Mon, 27 Sep 2004 17:04:52 +0100
From: José Luis Pérez Diez <jluis@agujero-negro.escomposlinux.org>
Subject: Re: Precedence of exponentiation
Message-Id: <VA.00000828.1b7f34ef@agujero-negro.escomposlinux.org>
In article <1096260839.GO/RR5PNg+xP+vWX0dEBRg@teranews>, David Frauzel
wrote:
> Am I really in the minority in thinking that -2**4 should mean (-2)**4?
>
What shold 4-2**4 mean?
Error or 4-(2**4) or (4-2)**4 or (4,16)
------------------------------
Date: 27 Sep 2004 17:31:07 GMT
From: ctcgag@hotmail.com
Subject: Re: Precedence of exponentiation
Message-Id: <20040927133107.128$mv@newsreader.com>
David Frauzel <nemo@weathersong.net> wrote:
> Rhetorical question.
>
> Why does Perl give such high precedence to the exponentiation operator,
> "**"?
Because that is the way that the people who mostly use exponentiation
expect it to happen.
> perlop makes it very clear that -2**4 is equivalent to -(2**4), not (-2)
> **4. So -2**4 gives you -16, not 16. So Perl facilitates people who
> prefer unary operators to have less significance than binary operators,
> which seems to be completely counter to the general rules of algebra.
Where did you learn the general rules of algebra? Exponentiation
binds tighter than negation. I suspect that the main reason this decision
was made so that the negation would always be meaningful. (If it bound
tighter than exponentiation, it would be trivial in the case of even
exponent, and often illegal in the case of most fractional exponents [until
you get to imaginary numbers]). So we interpret in the way that makes it
more often meaningful. But regardless of why it is interpreted that way,
that is the way it is interpreted.
> But that's not why I'm asking the question, actually. What bugs me is
> this:
>
> 2**-4
>
> ... gives you 2**(-4), not -(2**4).
Of course it does. The alternative is just laughable.
> Looking at 2**-4, it seems obvious
> that this should be the case, but it apparently defies the above stated
> precedence rule. A token parser should recognize that the unary minus has
> lower precedence than **, and push ** below the unary minus, in exactly
> the same way it would with -2**4.
Don't be ridiculous. The assymetry belongs to the negation, not the
exponentation. The unary negation negates the term to its right. Since
"2**" is not a term, and isn't to its right, it is not what it negates.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 27 Sep 2004 08:27:37 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Printing regex match
Message-Id: <slrnclg5a9.bpp.tadmc@magna.augustmail.com>
Tad McClellan <tadmc@augustmail.com> wrote:
> Joe Smith <Joe.Smith@inwap.com> wrote:
>> Dave wrote:
>>
>>> if ( my ( @match ) = $string =~ /$pattern/smg ) { ... }
>>
>> I hope you realize that that can, in general, fail to match.
>>
>> if ( my ( @match ) = $string =~ /\Q$pattern\E/smg ) { ... }
>
>
> I hope you realize that m//sm are no-op modifiers if you are
> going to escape dots and anchors.
Errr, and even more importantly, @match isn't likely to have
very interesting contents if we backslash memory parens.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 27 Sep 2004 06:23:34 -0700
From: karu_bs@yahoo.com (Karuna)
Subject: Problem in getting results on browser ...
Message-Id: <88dfb20a.0409270523.505e7b@posting.google.com>
Hi
Am facing a strange problem wherein I am trying to run some tests
from browser.
My work flow goes like this :
Front-end (HTML/Javascript) - CGI - Back End (Perl scripts).
From the UI I select few testcases and invoke some
perl code from CGI script. That testcases would in turn
will run on a diff machine and return back the result.
I store all the logs in a logfile and parse it and print
it as PASSED if I find the string "TEST PASSED" and print
as FAILED if I find it as "TEST FAILED".
But problem is I could see only some part of the data on
the browser after tests have started. It will print few
lines say "Running Testcase - xxx " which I would have
printed in CGI code itself before I started running tests
in the CGI code.
But once data gets printed on the browser tests would still
be in running in the background. And I can never see any
data like "TEST PASSED " or "TEST FAILED" and links to
LOGS am providing.
And this happens (sudden exit at browser level) exactly at
3-4 mins from the time I would have started running tests.
I dont think its a httpd.conf problem too as I have set reasonably
long timeout in httpd.conf file.
Experts please please help me in this.
regards
Karuna
------------------------------
Date: 27 Sep 2004 13:36:59 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Problem in getting results on browser ...
Message-Id: <Xns9571620457EFDasu1cornelledu@132.236.56.8>
karu_bs@yahoo.com (Karuna) wrote in
news:88dfb20a.0409270523.505e7b@posting.google.com:
> Hi
>
> Am facing a strange problem wherein I am trying to run some tests
> from browser.
>
>
> My work flow goes like this :
>
> Front-end (HTML/Javascript) - CGI - Back End (Perl scripts).
...
> But problem is I could see only some part of the data on
> the browser after tests have started. It will print few
> lines say "Running Testcase - xxx " which I would have
> printed in CGI code itself before I started running tests
> in the CGI code.
Where is that CGI code?
Surely, you are not claiming that you are outputting to stdout before you
send headers in your CGI script ... or are you?
Note that this is most likely a CGI question and not a Perl question.
> But once data gets printed on the browser tests would still
> be in running in the background. And I can never see any
> data like "TEST PASSED " or "TEST FAILED" and links to
> LOGS am providing.
>
> And this happens (sudden exit at browser level) exactly at
> 3-4 mins from the time I would have started running tests.
>
> I dont think its a httpd.conf problem too as I have set reasonably
> long timeout in httpd.conf file.
>
> Experts please please help me in this.
Honestly, what makes you think we can say antyhing without seing code?
Write a small, self-contained script that demonstrates your problem. In the
process, you'll either solve your problem, or end up with code other people
can help with.
Sinan.
------------------------------
Date: 27 Sep 2004 13:10:18 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: references to filehandle?
Message-Id: <Xns95715D7E298F3asu1cornelledu@132.236.56.8>
Stefan H. <stfhostf@kartos.de> wrote in
news:v4dfl09g668sar4tte94g1rqega01cbp2f@4ax.com:
> On 27 Sep 2004 03:29:11 GMT, "A. Sinan Unur" <usa1@llenroc.ude.invalid>
> wrote:
>
>>Ahem ... I do not see anything that is separated using ;
>
> sorry, I forgot to mention that the data files are semicolon separated
> file
Well, it looks like you should also read the posting guidelines posted here
frequently. The code you posted was not runnable and the data you posted
was not real. That is not nice.
>> print $out "@{[ join ';', @fields ]}\n";
>> } else {
>> warn "Cannot open $fields[1].csv: $!";
>
> you don't close the open filehandles. Is this ok?
THe original code was:
>> if(open my $out, '>>', "$fields[1].csv") {
>> print $out "@{[ join ';', @fields ]}\n";
I know Michele has already responded to this but here's my two cents.
The crucial part is that the file is opened using open my $out, i.e. the
scope of $out is limited to the if-block. $out is a lexical filehandle.
Lexical filehandles are automatically closed upon going out of scope. On
the other hand, you can also explicitly close them. In fact, that would be
the only way to catch a failure on close.
Sinan.
------------------------------
Date: Mon, 27 Sep 2004 15:35:08 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: references to filehandle?
Message-Id: <gn5gl01td91vh5cnn2goss2vl34j2qp4pl@4ax.com>
On Mon, 27 Sep 2004 14:02:31 +0200, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> open my $fh, '>', $m or
> die "Can't write to `$_': $!\n";
Sorry, this should be
open my $fh, '>', $m or
die "Can't write to `$m': $!\n";
of course.
Hope there are no more typos left,
Michele
--
#!/usr/bin/perl -lp
BEGIN{*ARGV=do{open $_,q,<,,\$/;$_}}s z^z seek DATA,11,$[;($,
=ucfirst<DATA>)=~s x .*x q^~ZEX69l^^q,^2$;][@,xe.$, zex,s e1e
q 1~BEER XX1^q~4761rA67thb ~eex ,s aba m,P..,,substr$&,$.,age
__END__
------------------------------
Date: 27 Sep 2004 13:41:22 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: references to filehandle?
Message-Id: <Xns957162C243559asu1cornelledu@132.236.56.8>
Michele Dondi <bik.mido@tiscalinet.it> wrote in
news:gn5gl01td91vh5cnn2goss2vl34j2qp4pl@4ax.com:
> open my $fh, '>', $m or
> die "Can't write to `$m': $!\n";
>
> of course.
>
>
> Hope there are no more typos left,
Strictly speaking, not a typo, but I am going to suggest dropping the \n
from the error message.
Sinan.
------------------------------
Date: Mon, 27 Sep 2004 16:46:10 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: references to filehandle?
Message-Id: <ui9gl01rshnj8p3vgckh3jf3utkidu8hd7@4ax.com>
On 27 Sep 2004 13:41:22 GMT, "A. Sinan Unur"
<usa1@llenroc.ude.invalid> wrote:
>> open my $fh, '>', $m or
>> die "Can't write to `$m': $!\n";
[snip]
>> Hope there are no more typos left,
>
>Strictly speaking, not a typo, but I am going to suggest dropping the \n
>from the error message.
Hehe! Opinions tend to vary here... IMHO the user should not be
interested in the additional info that omitting \n supplies, and I
find that generally this is the case. Well in this case, he/she may be
interested in the line of input that triggered it, but hopefully
knowing "which $m" is the guilty one should be enough. OTOH you should
have noticed that my code contained also a \n-less warn() because in
that case it seemed to mo more meaningful to do so...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 27 Sep 2004 06:09:33 -0700
From: nospam87@hotmail.com (Big Tony)
Subject: Regular expression don't match sequence of characters
Message-Id: <311e0f60.0409270509.f0fe58@posting.google.com>
Hi
I suspect this is an easy one and sits somewhere in a FAQ, but can
anyone help anyway?
Suppose I have two strings:
$str1 = "abcd%efg";
$str2 = "1234\%567";
I would a regular expression that will return "abcd" from $str1 and
"1234\%567" from $str2, i.e. if a "%" is encountered without being
preceded by a "\" then ignore it and the remainder of the string, but
if "\%" is encountered do nothing special and return it with the rest
of the string.
I guess I could use split to break the strings around the "%" and then
test for a trailing "\", but wondered if anyone could come up with a
one-liner.
cheers
BT
------------------------------
Date: 27 Sep 2004 13:43:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular expression don't match sequence of characters
Message-Id: <cj95ek$fep$1@mamenchi.zrz.TU-Berlin.DE>
Big Tony <nospam87@hotmail.com> wrote in comp.lang.perl.misc:
> Hi
>
> I suspect this is an easy one and sits somewhere in a FAQ, but can
> anyone help anyway?
>
> Suppose I have two strings:
> $str1 = "abcd%efg";
> $str2 = "1234\%567";
Note that $str2 does *not* contain a backslash. Either use single
quotes, or double the \:
$str2 = '1234\%567';
or
$str2 = "1234\\%567"
> I would a regular expression that will return "abcd" from $str1 and
> "1234\%567" from $str2, i.e. if a "%" is encountered without being
> preceded by a "\" then ignore it and the remainder of the string, but
> if "\%" is encountered do nothing special and return it with the rest
> of the string.
> I guess I could use split to break the strings around the "%" and then
> test for a trailing "\", but wondered if anyone could come up with a
> one-liner.
Let's first find a regex that matches a single "%", but not a "\%".
You want negative lookbehind for that:
/(?<!\\)%/
(Again, \ must be doubled in double-quotish context.)
To delete that match, plus everything that follows, do
s/(?<!\\)%.*//;
Anno
------------------------------
Date: Mon, 27 Sep 2004 08:43:32 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular expression don't match sequence of characters
Message-Id: <slrnclg684.bpp.tadmc@magna.augustmail.com>
Big Tony <nospam87@hotmail.com> wrote:
> Suppose I have two strings:
> $str1 = "abcd%efg";
> $str2 = "1234\%567";
I guess you haven't tried print()ing the value of $str2 at this point, huh?
> I would a regular expression that will return "abcd" from $str1 and
> "1234\%567" from $str2, i.e. if a "%" is encountered without being
> preceded by a "\" then ignore it and the remainder of the string, but
> if "\%" is encountered do nothing special and return it with the rest
> of the string.
None of your strings have a percent preceded by a backslash...
Anyway, you can use a "negative look-behind":
-------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
foreach ( 'abcd%efg', '1234\%567' ) {
print "string is '$_'\n";
# my( $stuff ) = /^(.*?)((?<!\\)%|$)/;
my( $stuff ) = /^(.*?) # bunch of chars until...
(
(?<!\\)% # ... a percent without preceding backslash
| # or
$ # end of string
)/sx;
print "stuff is '$stuff'\n";
}
-------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 27 Sep 2004 17:52:21 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Using C::Scan : How to ignore #includes ?
Message-Id: <cj9k0l$2uvo$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Abhinav
<matrix_calling@yahoo.dot.com>], who wrote in article <9qP5d.3$RZ2.83@news.oracle.com>:
> For the above file, it rightly gives
>
> int func1( int x,
> int y,
> int z);
>
> I am using this string, returned from C::Scan, to match the protoype in the
> file, and comment it out. Thus, the modified file I have should have the
> prototype for func1 commented out.
>
> However, since C::Scan->get('fdecls') strips of comments, I am having a
> problem.
C::Scan needs to write statement/declaration boundaries. To do this,
it needs to deal with whatever is "not C code": preprocessor directives,
comments, literal strings.
The first thing C::Scan does is running the input through
preprocessor. Then the only (?) thing it needs to work with is literal
strings (it needs to ignore C code which is embedded in literal
strings, right?).
As I said, you can use `cat' as a preprocessor; but C::Scan may get
confused by the unpreprocessed code.
Hope this helps,
Ilya
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7183
***************************************