[23427] in Perl-Users-Digest
Perl-Users Digest, Issue: 5644 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 10 18:06:07 2003
Date: Fri, 10 Oct 2003 15:05:13 -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 Fri, 10 Oct 2003 Volume: 10 Number: 5644
Today's topics:
Re: Accepting HTTP Post <glex_nospam@qwest.net>
Re: Accepting HTTP Post nobull@mail.com
Re: Bug in File::Copy or my mistake? <syscjm@gwu.edu>
Conditional options to a regexp match? <dwake.no.spam@alumni.stanford.org>
Re: Conditional options to a regexp match? <jorge.b@rrios.com>
Re: Conditional options to a regexp match? <krahnj@acm.org>
Re: Conditional options to a regexp match? <michael.p.broida@boeing_oops.com>
Re: Conditional options to a regexp match? <cenxnfu@rpr.nevmban.rqh>
Re: data manipulation nobull@mail.com
Re: data manipulation <krahnj@acm.org>
Re: Efficient field splitting? unpack or substr or rege (ifiaz)
Re: Efficient field splitting? unpack or substr <kkeller-usenet@wombat.san-francisco.ca.us>
mod_perl / Apache problem (David)
Re: mod_perl / Apache problem <twhu@lucent.com>
Re: mod_perl / Apache problem <tore@aursand.no>
Re: mod_perl / Apache problem <konny@waitrose.com>
Re: mod_perl / Apache problem (David)
Net::SSH::Perl : multiple connections fails (Helge Cramer)
Re: Net::SSH::Perl : multiple connections fails <vladimir@NoSpamPLZ.net>
odd regexp behaviour (?) (bengt wikenfalk)
Re: odd regexp behaviour (?) <grazz@pobox.com>
Re: odd regexp behaviour (?) <xx087@freenet.carleton.ca>
Re: Opinions on "new SomeObject" vs. "SomeObject->new() <perl@my-header.org>
Re: Passing objects to a perl script via POST <glex_nospam@qwest.net>
Re: Perl Examples <jds@trumpetweb.co.uk>
Re: Remembering part of last matched string <noreply@gunnar.cc>
Re: Remembering part of last matched string <perl@my-header.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 10 Oct 2003 10:15:34 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: Accepting HTTP Post
Message-Id: <K%zhb.403$9P5.20115@news.uswest.net>
Raj wrote:
> Hi,
>
> I was wondering if it is straightforward to allow someone to post an XML
> file to a Perl-CGI script on a web server and storing that file on the web
> server?
Yes
> Can anyone help?
Documentation is the first stop.
perldoc CGI
Storing the data will require the correct permissions, but you'd send
XML just like you'd send any other string of data or file of data. If
you have an file, in XML, that you'd like to upload, look in the CGI
docs for "filefield".
------------------------------
Date: 10 Oct 2003 11:23:42 -0700
From: nobull@mail.com
Subject: Re: Accepting HTTP Post
Message-Id: <4dafc536.0310101023.7d6cb698@posting.google.com>
"Raj" <raj.kothary@thus.net> wrote in message news:<bm64fh$3p0$1$8300dec7@news.demon.co.uk>...
> I was wondering if it is straightforward to allow someone to post an XML
> file to a Perl-CGI script on a web server and storing that file on the web
> server?
Do you really mean a raw post post of an XML file (like a SOAP client
would), not post an HTML form response containing a file field
containing an XML file?
Anyhow the file type is irrelevant.
For HTML file fields use the CGI module.
For a raw file post do not use the CGI module, just use File::Copy
from \*STDIN.
------------------------------
Date: Fri, 10 Oct 2003 14:39:47 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Bug in File::Copy or my mistake?
Message-Id: <3F86FCF3.4070701@gwu.edu>
Gerhard Lausser wrote:
> Hi all,
>
> File::Copy::copy($source, $target) destroys both files if they are hard
> linked.
>
> here is what i did:
> lp0056:/tmp # echo "hihihihihi" > aaaa
> lp0056:/tmp # ln aaaa bbbb
> lp0056:/tmp # ln -s aaaa cccc
> lp0056:/tmp # ls -l aaaa bbbb cccc
> -rw-r--r-- 2 root root 11 Oct 10 16:07 aaaa
> -rw-r--r-- 2 root root 11 Oct 10 16:07 bbbb
> lrwxrwxrwx 1 root root 4 Oct 10 16:08 cccc -> aaaa
> lp0056:/tmp # perl -e 'use File::Copy; copy("/tmp/cccc", "/tmp/aaaa");'
> '/tmp/cccc' and '/tmp/aaaa' are identical (not copied) at -e line 1
> lp0056:/tmp # perl -e 'use File::Copy; copy("/tmp/bbbb", "/tmp/aaaa");'
> lp0056:/tmp # ls -l aaaa bbbb cccc
> -rw-r--r-- 2 root root 0 Oct 10 16:10 aaaa
> -rw-r--r-- 2 root root 0 Oct 10 16:10 bbbb
> lrwxrwxrwx 1 root root 4 Oct 10 16:08 cccc -> aaaa
>
> If i try to copy a softlink to its own target, copy complains.
> However if i copy hard linked files onto each other, both get zeroed.
> Looking at sub copy in File/Copy.pm i found code that tests if
> you copy a symbolic link but nothing to handle the hard link scenario.
>
> Is this the normal behaviour or is this a bug?
I'd call it a bug. Standard Unix cp checks to see if the files
are the links to the same file, whether they're hardlinks or
softlinks.
Chris Mattern
------------------------------
Date: 10 Oct 2003 13:23:51 -0700
From: David Wake <dwake.no.spam@alumni.stanford.org>
Subject: Conditional options to a regexp match?
Message-Id: <9nd6d43kq0.fsf@Turing.Stanford.EDU>
I want to do a case-insensitive regexp match if and only if the variable
$insensitive is set.
One way would be
if ($insensitive) {
/($pattern)/i;
}
else {
/($pattern)/;
}
Is there any way to do this with only one line of regexp searching?
I tried this:
my $searchoption = "";
$searchoption .= "i" if $insensitive;
/($pattern)/$searchoption;
but I get a syntax error.
Obviously, if we have three or four options the problem gets
exponentially bigger. For example, options for "i", "s" and "g" would
require eight possibilities. So it would be a big help if there is an
easy way to do this!
Thanks,
David
------------------------------
Date: Fri, 10 Oct 2003 20:50:17 GMT
From: Jorge Barrios <jorge.b@rrios.com>
Subject: Re: Conditional options to a regexp match?
Message-Id: <m3wubcsxb0.fsf@www.drakonis.com>
David Wake <dwake.no.spam@alumni.stanford.org> writes:
> I want to do a case-insensitive regexp match if and only if the variable
> $insensitive is set.
>
> One way would be
>
> if ($insensitive) {
> /($pattern)/i;
> }
> else {
> /($pattern)/;
> }
>
> Is there any way to do this with only one line of regexp searching?
$insensitive ? /($pattern)/i : /($pattern)/;
is a possibility
--
Jorge Barrios
------------------------------
Date: Fri, 10 Oct 2003 21:24:22 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Conditional options to a regexp match?
Message-Id: <3F87237B.198F7C2E@acm.org>
David Wake wrote:
>
> I want to do a case-insensitive regexp match if and only if the variable
> $insensitive is set.
>
> One way would be
>
> if ($insensitive) {
> /($pattern)/i;
> }
> else {
> /($pattern)/;
> }
>
> Is there any way to do this with only one line of regexp searching?
>
> I tried this:
>
> my $searchoption = "";
> $searchoption .= "i" if $insensitive;
> /($pattern)/$searchoption;
>
> but I get a syntax error.
>
> Obviously, if we have three or four options the problem gets
> exponentially bigger. For example, options for "i", "s" and "g" would
> require eight possibilities. So it would be a big help if there is an
> easy way to do this!
/(?@{[ $insensitive ? 'i' : '' ]}:($pattern))/;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 10 Oct 2003 21:15:15 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Conditional options to a regexp match?
Message-Id: <3F872163.3FE70C54@boeing_oops.com>
David Wake wrote:
>
> I want to do a case-insensitive regexp match if and only if the variable
> $insensitive is set.
>
> One way would be
>
> if ($insensitive) {
> /($pattern)/i;
> }
> else {
> /($pattern)/;
> }
>
> Is there any way to do this with only one line of regexp searching?
>
> I tried this:
>
> my $searchoption = "";
> $searchoption .= "i" if $insensitive;
> /($pattern)/$searchoption;
>
> but I get a syntax error.
>
> Obviously, if we have three or four options the problem gets
> exponentially bigger. For example, options for "i", "s" and "g" would
> require eight possibilities. So it would be a big help if there is an
> easy way to do this!
Something with "eval"?? Something like:
$matchstatement = "\$x = m/(\$pattern)/"; # add escapes (\) as needed
if ($insensitive) $matchstatement .= "i"; # append desired options
if ($global) $matchstatement .= "g"; # ditto
...
eval $matchstatement; # I don't know the "eval" syntax :)
Don't know if that's "safe", but it seems like it
oughta work. :)
Mike
------------------------------
Date: Fri, 10 Oct 2003 14:51:32 -0700
From: Cognition Peon <cenxnfu@rpr.nevmban.rqh>
Subject: Re: Conditional options to a regexp match?
Message-Id: <Pine.GSO.4.50.0310101440360.26728-100000@shellfish.ece.arizona.edu>
9:24pm, IP packets from John W. Krahn delivered:
>
> /(?@{[ $insensitive ? 'i' : '' ]}:($pattern))/;
>
Great solution. Thanks!! Never seen an example of
(?imsx) regular expression extension before.
>
>
> John
>
--
echo cenxnfu@rpr.nevmban.rqh | perl -pe 'y/A-Za-z/N-ZA-Mn-za-m/'
Q: How many CPU's does it take to execute a job?
A: Four. Three to hold it down, and one to rip its head off.
------------------------------
Date: 10 Oct 2003 11:16:39 -0700
From: nobull@mail.com
Subject: Re: data manipulation
Message-Id: <4dafc536.0310101016.3f7e49b1@posting.google.com>
"Bob" <bNOoONb@not.pilbara.net.au> wrote in message news:<1065795089.153636@cube.norcom.net.au>...
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnbod9bh.4eg.tadmc@magna.augustmail.com...
> > Bob <bNOoONb@not.pilbara.net.au> wrote:
> >
> > > if (@ARGV == "0" ) {
> >
> > Why use a numeric operator and then force stringification?
> >
> > If you want to test a number, use a number and a numeric operator:
> >
> > if (@ARGV == 0 ) {
> >
> > If you want to test a string, use a string and a string operator
> >
> > if (@ARGV eq "0" ) {
>
>
> Ok, what I am trying to test for is the existance of an argument, - if
> @ARGV is NULL .... do something..... what I use works, but if there is a
> better way of testing for a NULL than a numerical comparison?
Yep, simple boolean context.
unless (@ARGV) {
> suggestions.... In this case, where the array is empty, a numeric test
> returns "0", so the test made sense.
No, I cannot see any reason why it never makes sense to use a string
literal in a numeric context. (Of course the compiler optomises the
string-to-number convertions out).
> > > open (MyFILE, $file2);
> >
> >
> > You should always, yes *always*, check the return value from open():
> >
> > open(MyFILE, $file2) or die "could not open '$file2' $!";
> >
>
> In this case, I know that 1 of the 2 files will always exist, so I did not
> "or die" here, but for the sake of consistency I will add it.
No it's not just for consistency. It's a good programming habit so
that if something sometime in the future breaks you get a useful
error.
------------------------------
Date: Fri, 10 Oct 2003 18:20:21 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: data manipulation
Message-Id: <3F86F85B.8FA63C90@acm.org>
Bob wrote:
>
> Thanks for the explanation, And I already understood the implication of the
> whole file being in memory. In this case, it is not a problem, the log is
> generally ony 3-5Meg but never over 50Meg.
>
> For those interested, I have included the full script below
>
> #!/usr/bin/perl
> #
> # NAME qmail-qreadto
> # purpose - look thru the qmail-qread logs for particular messages
> #
> use strict;
> use warnings;
>
> if (@ARGV == "0" ) {
That is usually written as:
unless ( @ARGV ) {
> print "\n\tqmail-qreadto \{ email to search for\} \n";
> print "\t\texample\: qmail-qreadto me\@example.net \n\n";
> exit 0
> }
>
> my ($Log, @Logs);
> my $file1 = "/var/log/qmail-qread";
> my $file2 = "/var/log/qmail-qread1";
>
> if (-e $file2 ) {
> open (MyFILE, $file2);
> } else {
> open (MyFILE, $file1);
> }
What happens if the file is unlinked or moved between the time you stat
the file and the time you open the file? What happens if neither $file1
nor $file2 exists? This is better:
open MyFILE, $file2
or open MyFILE, $file1
or die "Cannot open $file2 or $file1: $!";
> while (<MyFILE>) {
> if (/^\d{1,2}/) {
> push @Logs, $Log if $Log;
> $Log = '';
> }
> $Log .= $_;
> }
>
> close MyFILE;
>
> push @Logs, $Log;
>
> print grep {/@ARGV/} @Logs;
The match operator m// interpolates its contents just like a double
quoted string so if you have more then one element in @ARGV this will
not work. You probably want:
print grep /\Q$ARGV[0]/, @Logs;
Or you could test the contents of $Log before you push it into @Logs:
push @Logs, $Log if $Log =~ /\Q$ARGV[0]/;
> exit 0;
John
--
use Perl;
program
fulfillment
------------------------------
Date: 10 Oct 2003 10:44:20 -0700
From: ifiaz@hotmail.com (ifiaz)
Subject: Re: Efficient field splitting? unpack or substr or regex
Message-Id: <93c1947c.0310100944.30257802@posting.google.com>
> I have found that unpack is significantly slower as well. I can't say
> conclusively why, but my guess is that it's built to do much more than
> just extract certain characters from a string the way you appear to be
> using it.
>
> Believe it or not, a regex is very fast at this sort of thing if
> performance is a major concern.
>
> my $string = 'one two three four';
> my ($o,$tw,$th,$f) = $line =~ /^(...).(...).(.....).(....)/;
> # or /^(.{3}).(.{3}).(.{5}).(.{4})/
>
> Benchmark this against substr with your data, and I think you'll find
> that this is much faster. In past cases where I've looked to do
> something similar, the regex has won, except in cases where I've
> needed only a small portion of the large string.
I did try to use the regex as you have told me.
But, infact it is slower than substr.
I forgot the time it took, it is about 21 seconds (certainly
greater than 20 seconds). Since I am at home now for the
weekend, I can't verify it exactly about the seconds.
Thanks to all of you. If you have any further input on this
you are most certainly welcome.
------------------------------
Date: Fri, 10 Oct 2003 08:22:02 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Efficient field splitting? unpack or substr
Message-Id: <qqi6mb.vpr.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
On 2003-10-10, ifiaz <ifiaz@hotmail.com> wrote:
>
> The fields are fixed-widths. You can't extract it using delimiters as
> some of the
> fields may be blank.
If your delimiters are spaces, sure. If you are able to generate the
file using a different delimiter (tab is a common one) then maybe
splitting on the delimiter will be easier. Your only concern would be
to pick a character that you know for certain doesn't appear in any of
your data fields.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj+GzpgACgkQhVcNCxZ5ID+GAACfTbqQ/uY+Mgy8iwjSX10lTuky
vvUAoIqgXfoDC2deKM9AcnN8FWNGZ2i7
=n5+s
-----END PGP SIGNATURE-----
------------------------------
Date: 10 Oct 2003 08:21:16 -0700
From: superman183@hotmail.com (David)
Subject: mod_perl / Apache problem
Message-Id: <1d4e2ae4.0310100721.5202a028@posting.google.com>
Hi,
Hopefully this is being posted in the right place - apologies in
advance if not.
I'm having trouble getting mod_perl and Apache to work together on a
Windows XP Pro' machine. I can get the server to work fine for normal
Perl, but not for mod_perl. All I end up with are error 500's.
I have modified the httpd.conf file several times, and restarted etc,
etc, but no luck. The additions to my .conf file are as follows:
Alias /cgi-perl/ "E:/Apache2/cgi-perl/"
<Location /cgi-perl>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader on
Options ExecCGI
</Location>
<Location /perl-status>
SetHandler perl-script
PerlHandler Apache::Status
order deny,allow
deny from all
allow from 172.10.1.8
</Location>
... I'm obviously on the internal IP address of 172.10.1.8, and I'm
trying to test a script in http://.../cgi-perl/test.cgi
The same script works fine in /cgi-bin/.
My environment variables and server signature indicate the mod_perl is
installed, as follows:
SERVER_SOFTWARE Apache/2.0.46 (Win32) mod_perl/1.99_10-dev Perl/v5.8.0
PHP/4.3.2 mod_ssl/2.0.46 OpenSSL/0.9.7b
SERVER_SIGNATURE
Apache/2.0.46 (Win32) mod_perl/1.99_10-dev Perl/v5.8.0 PHP/4.3.2
mod_ssl/2.0.46 OpenSSL/0.9.7b Server at 172.10.1.8 Port 79
GATEWAY_INTERFACE CGI/1.1
Now I know that for mod_perl the GATEWAY_INTERFACE should be reading
as something other than CGI/1.1 ... but have tried all sorts of stuff
to no avail.
If I look in the server error logs, then I can see:
Can't locate Apache/Registry.pm in @INC (@INC contains:
E:/Perl/site/lib/ E:/Perl/site/lib/Apache2 E:/Perl/lib
E:/Perl/site/lib . E:/Apache2/ E:/Apache2/lib/perl) at (eval 37) line
3.
....
I do see Registry.pm in E:/Perl/site/lib/Win32/ and
E:/Perl/site/lib/Win32API/ ... but I can't help thinking that my
problem is not to do with that, since with the paths given above, then
Apache should be able to find them ...
I have actually un-installed and re-installed everything from the
ground up, but still seem to be missing something ...
Any help very much appreciated!
Thanks.
------------------------------
Date: Fri, 10 Oct 2003 12:25:55 -0400
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: mod_perl / Apache problem
Message-Id: <bm6ml0$h1k@netnews.proxy.lucent.com>
"David" <superman183@hotmail.com> wrote in
[snip]
> If I look in the server error logs, then I can see:
>
> Can't locate Apache/Registry.pm in @INC (@INC contains:
> E:/Perl/site/lib/ E:/Perl/site/lib/Apache2 E:/Perl/lib
> E:/Perl/site/lib . E:/Apache2/ E:/Apache2/lib/perl) at (eval 37) line
> 3.
> ....
>
> I do see Registry.pm in E:/Perl/site/lib/Win32/ and
> E:/Perl/site/lib/Win32API/ ... but I can't help thinking that my
> problem is not to do with that, since with the paths given above, then
> Apache should be able to find them ...
I don't know how you installed your stuff. However, the error
message said it cannot find the
E:/Perl/site/lib/Apache/Registry.pm or
E:/Perl/site/lib/Apache2/Apache/Registry.pm or
E:/Perl/libApache/Registry.pm or
E:/Perl/site/libApache/Registry.pm or
E:/Apache2/Apache/Registry.pm or
E:/Apache2/lib/perlApache/Registry.pm
The @INC does not include E:/Perl/site/lib/Win32/, so even your
Apache/Registry.pm is under that directory. Perl still cannot find it.
Tulan
------------------------------
Date: Fri, 10 Oct 2003 19:17:39 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: mod_perl / Apache problem
Message-Id: <pan.2003.10.10.16.58.56.293943@aursand.no>
On Fri, 10 Oct 2003 08:21:16 -0700, David wrote:
> Hopefully this is being posted in the right place
I don't think so. This is related to the Apache web server, not Perl.
You should try one of the Apache newsgroups.
Good luck!
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Fri, 10 Oct 2003 20:21:30 +0100
From: Mr I <konny@waitrose.com>
Subject: Re: mod_perl / Apache problem
Message-Id: <qgdj51-jfa.ln1@sam.amaretti.net>
Tore Aursand wrote:
> On Fri, 10 Oct 2003 08:21:16 -0700, David wrote:
>
>>Hopefully this is being posted in the right place
>
>
> I don't think so. This is related to the Apache web server, not Perl.
> You should try one of the Apache newsgroups.
>
> Good luck!
>
>
Agreed.
But here's some help to wing you on your way.
http://perl.apache.org/docs/2.0/os/win32/install.html
http://perl.apache.org/docs/1.0/guide/getwet.html
You will need a startup file to adjust the Perl modules search paths in
@INC.
Investigate the apache directive
PerlRquire
Have a google for mod_perl 2 and that will probably help you.
K
------------------------------
Date: 10 Oct 2003 14:56:23 -0700
From: superman183@hotmail.com (David)
Subject: Re: mod_perl / Apache problem
Message-Id: <1d4e2ae4.0310101356.47197fd2@posting.google.com>
Tore Aursand <tore@aursand.no> wrote in message news:<pan.2003.10.10.16.58.56.293943@aursand.no>...
> On Fri, 10 Oct 2003 08:21:16 -0700, David wrote:
> > Hopefully this is being posted in the right place
>
> I don't think so. This is related to the Apache web server, not Perl.
> You should try one of the Apache newsgroups.
>
> Good luck!
Hmmm, one can't help thinking that mod_perl, and by association
Apache, is in fact somehow related to Perl ... that is after all the
whole point of mod_perl.
------------------------------
Date: 10 Oct 2003 09:04:23 -0700
From: cramer@crpc.de (Helge Cramer)
Subject: Net::SSH::Perl : multiple connections fails
Message-Id: <7c754dd5.0310100804.234e47aa@posting.google.com>
I installed Net::SSH::Perl and everything works fine ;-)
But trying to connect to multiple servers brings out error-message:
Net::SSH: Can't bind socket to port 1023
$ssh1 = Net::SSH::Perl->new('host1', protocol => '2,1');
$ssh2 = Net::SSH::Perl->new('host2', protocol => '2,1');
Alternatively, I tried to set up the second connection after remote
commands on first connection exited, but it just brought up the same
error.
I think, I am missing a hint for "unbinding" the socket/close the
connection before connect to second server or a hint for an
opportunity to speak with both servers at the same time.
I am running RedHat9 on an intel-box and on remote servers sshd is
listening to port 23 only.
Thanks for any hint/solution,
Helge Cramer
------------------------------
Date: Fri, 10 Oct 2003 20:22:16 GMT
From: lostriver <vladimir@NoSpamPLZ.net>
Subject: Re: Net::SSH::Perl : multiple connections fails
Message-Id: <YxEhb.41170$nh4.641074@weber.videotron.net>
On 10 Oct 2003 09:04:23 -0700, Helge Cramer wrote:
> I installed Net::SSH::Perl and everything works fine ;-)
> But trying to connect to multiple servers brings out error-message:
>
> Net::SSH: Can't bind socket to port 1023
You are not runing it as root, right? Only root can use local ports 0-1023....
Are you sure you do not have 'privileged => 1' set?
--
.signature: No such file or directory
------------------------------
Date: 10 Oct 2003 08:35:49 -0700
From: benwik@hotmail.com (bengt wikenfalk)
Subject: odd regexp behaviour (?)
Message-Id: <9cc25645.0310100735.243c3166@posting.google.com>
Hi.
I wonder about the difference between =~ and = ~
I wrote a script with the following expression:
return $c if ($name = ~ /^OK$/);
($name is an array reference (ARRAY=0x....)
This works ! (if the array contains the string "OK", $c will be returned.
if I change the code to $name =~ ... it does not work however (which
actually makes me relieved ..)
Is this a standard feature ? Can anyone describe what happens here ?
(I'm running Perl 5.6 under cygwin)
------------------------------
Date: Fri, 10 Oct 2003 16:28:45 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: odd regexp behaviour (?)
Message-Id: <17Bhb.37$0I6.8@nwrdny03.gnilink.net>
bengt wikenfalk <benwik@hotmail.com> wrote:
> I wonder about the difference between =~ and = ~
"=~" is one operator. "= ~" is two.
#!/usr/bin/perl -l
$_ = "foo";
$str = "bar";
if ($str =~ /bar/) {
print "$str matched /bar/";
}
if ($str = ~ /foo/) {
print "\$str is $str";
print "That's ~1: ", ~1;
}
--
Steve
------------------------------
Date: 10 Oct 2003 17:02:06 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: odd regexp behaviour (?)
Message-Id: <slrnbodphg.ha8.xx087@smeagol.ncf.ca>
Steve Grazzini <grazz@pobox.com> wrote:
> bengt wikenfalk <benwik@hotmail.com> wrote:
> > I wonder about the difference between =~ and = ~
>
> "=~" is one operator. "= ~" is two.
>
> #!/usr/bin/perl -l
>
> $_ = "foo";
> $str = "bar";
>
> if ($str =~ /bar/) {
> print "$str matched /bar/";
> }
>
> if ($str = ~ /foo/) {
> print "\$str is $str";
> print "That's ~1: ", ~1;
> }
Also:
$_ = '';
if ($str = ~ /foo/) {
print "\$str is $str";
print "That's ~0: ", ~0;
}
($str = ~ /foo/) means "assign to $str the bitwise negation of the
scalar result of matching /foo/ against $_". Note that both ~0 and ~1
are non-zero, hence true.
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Fri, 10 Oct 2003 18:03:13 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <ekidovsrbddfpptrs2luqh8mtns33b3b1c@4ax.com>
X-Ftn-To: Iain Truskett
Iain Truskett <ict@eh.org> wrote:
>> great thing but first you have to //understand//
>> implications of your programming decisions.
>
>Perhaps you could draw up a list of guidelines, where for
>every guideline you also have a counter-guideline or three.
>
>Let people see what other people consider good practice and
>pick and mix between them =)
Ok, I'll write first commandment,
1) do "use strict;" in /all/ your programs until you learn from perldoc
strict. You are also free to continue such practice after this revelation.
(there is no counter-commandment for this one :))
--
Matija
------------------------------
Date: Fri, 10 Oct 2003 10:23:06 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: Passing objects to a perl script via POST
Message-Id: <N6Ahb.405$9P5.20802@news.uswest.net>
Jim Rendant wrote:
> I am new at web page design and was wondering if I created an object in java
> script or an array can I pass it back to a perl script for processing.
>
> One example my be where a customer has the ability to select multiple items
> from a single page. By using checkboxes the end user selects multiple item
> and enters quantities for those item. By passing some sort of data structure
> (array or object) back the script for processing.
>
> I know I can build an object in JavaScript populating it with pertinent
> information.
>
> Let me know what you think?
You can do what you want without any JavaScript.
If you're going to use perl to process the info, look at
perldoc CGI
Otherwise this is an HTML question and you'd be able to find more
information in an HTML related newsgroup or learning about processing
forms and CGI.
------------------------------
Date: Fri, 10 Oct 2003 18:27:15 +0100
From: "Julia deSilva" <jds@trumpetweb.co.uk>
Subject: Re: Perl Examples
Message-Id: <3XBhb.21$X53.18@news-binary.blueyonder.co.uk>
> I'm learning Perl and CGI with the book Visual Quickstart Guide by
> Elizabeth Castro. The problem is that I have the first edition book,
> while Castro only has Perl and CGI example files for her second edition
> book (available from her web site). Does anybody out there happen to
> still have the Perl and CGI examples from Castro's first book??
>
> I've emailed Castro, but have not received a response, as of yet.
>
While that book is OK for the most basic elements it doesn't mention
my, cgi.pm or strict, or warnings or slurping or ...........
and can get you off on the wrong track if you're not careful.
j
------------------------------
Date: Fri, 10 Oct 2003 17:04:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Remembering part of last matched string
Message-Id: <bm6htg$j4ac7$1@ID-184292.news.uni-berlin.de>
Chandramohan Neelakantan wrote:
> I have output from 'pdftotext' command and I need to parse the
> information in the text.
> The text is in a table format.
> This is a hardware design rules file and has associated
> information in these tables for every rule.
>
> For better understanding I have marked all new lines with \n and
> all spaces with ^
>
> Also
> - Each Rule begins with the number like 23.1 or 23.1.1
> - The 'Description' column can be spanned over several lines/rows
> with blank lines in between
> - Devices column could be empty
> - It is not possible to ascertain the width of each column
>
>
> -------------------------------------------------
> Rule Description Dimensions Devices Fig
> -------------------------------------------------
> 23.1^^^^^^^^^Text ^^^^^^^^^^^^2.0 x 4.9^^^^^^^ All ^^^^^^^^^^^2,F1\n
>
> except NPN\n
> \n
> ^^^^^^^^^^^^Text Here\n
>
>
>
>
> 23.1.1^^^^^^Text ^^^^^^^^^^^^^2.0x4.9^^^^^^^^^^^^^^^^^^^^^^^ 1,F1\n
> \n
> \n
> ^^^^^^^^^^^^Text Here\n
> ^^^^^^^^^^^^Text Here\n
>
>
>
> -------------------------------------------------
How about storing the values in a hash of hashes? This may be a start,
assuming the output is in $_:
my %rules = ();
while (
/(\d+(?:\.\d+)+) # Rule
\s+
([\w\-\s]+[\w\-]) # Description
\s+
(\d+\.\d\s?x\s?\d+\.\d) # Dimensions
\s+
([A-Z]*) # Devices
\s+
(\d,[A-Z]\d) # Fig
\s+
([\w\-\s]+[\w\-]) # except NPN
\s+
(?=\d+(?:\.\d+)+|$) # next rule or end
/gix
)
{
$rules{ $1 } = {
desc => $2,
dim => $3,
dev => $4,
fig => $5,
except => $6,
};
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 10 Oct 2003 18:03:14 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Remembering part of last matched string
Message-Id: <jmldovcoao9ggm1m3qrqqch46i25o1mgl6@4ax.com>
X-Ftn-To: Chandramohan Neelakantan
knchandramohan@yahoo.com (Chandramohan Neelakantan) wrote:
>The problems are
>- this is a row wise pattern matching approach and I do not know the
>end a rule until I see the start of another
>- Both the 'Description' and 'Devices' column contensts could be in
>several lines with blank lines in between
>
>I need to extract the information in all the columns for every rule
>and save it in a separate file.
my $s = rules...
for my $rule (split /(?:^|\n)(?=\d)/, $s) {
my($line, $restdesc) = split /\n+/, $rule, 2;
my @attr = split /\s\s+/, $line;
$attr [1] .= $restdesc;
print join '~', @attr;
print "\n";
}
I've assumed that every rule begins on newline and with at least one number.
Also, on the first line of the rule two or more whitespaces are considered
as field separator. You'll only have to check the size of @attr to see if
"Devices" is defined for particular rule.
--
Matija
------------------------------
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 5644
***************************************