[23329] in Perl-Users-Digest
Perl-Users Digest, Issue: 5549 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 23 11:06:04 2003
Date: Tue, 23 Sep 2003 08:05:09 -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 Tue, 23 Sep 2003 Volume: 10 Number: 5549
Today's topics:
Re: basic subroutine question. <kuujinbo@hotmail.com>
Re: CGI.pm <REMOVEsdnCAPS@comcast.net>
Re: CGI.pm <REMOVEsdnCAPS@comcast.net>
Re: CGI.pm <REMOVEsdnCAPS@comcast.net>
Classic ASP HTML Templates like Perl's HTML::Template? (C. Olive)
different encoding datastream; if using different (file <udo@lipsia.de>
Re: for; while loop interations <mooseshoes@gmx.net>
Re: for; while loop interations <ebohlman@earthlink.net>
Re: Form problems, post method yeilds 0 at end of value <mills_nospam_@free.fr>
Re: Form problems, post method yeilds 0 at end of value <mills_nospam_@free.fr>
Re: how to find the biggest ???? (Helgi Briem)
Re: how to find the biggest ???? (Chris Marshall)
How to return an HTML page from a Perl script ? <NoSpamPlease@bellsouth.net>
Re: How to return an HTML page from a Perl script ? <nobody@dev.null>
Re: How to return an HTML page from a Perl script ? <asu1@c-o-r-n-e-l-l.edu>
Net::POP3->new() fails in PerlApp compiled script <netnews1@mcdanielhome.com>
Re: Perl: how to stop users from executing commands fro <REMOVEsdnCAPS@comcast.net>
Re: read-only flag <terrylr@blauedonau.com>
Re: read-only flag <REMOVEsdnCAPS@comcast.net>
Re: RegExp: Matching (Anno Siegel)
Re: RegExp: Matching <abigail@abigail.nl>
Re: some proxies post and some won't with lwp (Robert)
Re: splitting lines <someone@somewhere.com>
Re: Stupid perl regexp question (G Klinedinst)
Re: Using variables in RegEx statements? <REMOVEsdnCAPS@comcast.net>
Re: WWW::Mechanize click() returns "Unexpected field va (Timur Tabi)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Sep 2003 19:05:27 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: basic subroutine question.
Message-Id: <bkp606$se3$1@pin3.tky.plala.or.jp>
ko wrote:
> #!/usr/bin/perl -w
> use strict;
>
> my @LoL = (
> [1,2,3,4,5],
> [2,10,7,15,14]);
>
> @LoL = to_remove(\@LoL, [0, 2]);
> print "@$_\n" foreach (@LoL);
>
> @LoL = to_remove(\@LoL, [0, 1]);
> print "@$_\n" foreach (@LoL);
>
> # make sure you pass in an array reference as the second argument
> sub to_remove {
> my($ar, $ar_remove) = @_;
> foreach my $element(@$ar) {
^^^^^^^^^^^^^^^^^^^^^^^^^^
change line above to:
foreach (sort { $a <=> $b } @$ar_remove) {
The elements need to be in numerical order, or it won't work...
> foreach (@$ar_remove) {
> my $to_remove = $_ ? $_ - 1 : 0;
> splice(@$element, $to_remove, 1);
> }
> }
> return @$ar;
> }
keith
------------------------------
Date: Tue, 23 Sep 2003 05:45:58 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: CGI.pm
Message-Id: <Xns93FF44D1D63E6sdn.comcast@206.127.4.25>
yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in news:3f6f5d49
@news.victoria.tc.ca:
> Trent Curry (tcurrey@no.no.no.i.said.no) wrote:
>: Jeff 'japhy' Pinyan wrote:
>: > On Mon, 22 Sep 2003, D Borland wrote:
>
>: >
>: >> Maybe PHP was the better choice.
>: >
>: > If what you need is web-based stuff, by all means, use PHP. That's
>: > what it's there for.
>
>: Perl works quite well for web apps too you know ;-p
>
> Yes, but it's at least as good to use php if you don't want to read the
> perl manuals.
>
What, you don't need to read any manuals in order to use PHP? :-)
--
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
------------------------------
Date: Tue, 23 Sep 2003 05:49:23 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: CGI.pm
Message-Id: <Xns93FF45662EBB7sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"D Borland" <notavailable@nospamplease.com> wrote in
news:BIUbb.7974$Ne.3174278@newsfep2-win.server.ntli.net:
> What r u talking about!???!!!!
>
Top-posting is the practice of writing your follow-up above the text that
you're quoting. Most regulars here in comp.lang.perl.misc (and in
technical newsgroups in general) find this style extremely annoying. It
makes it difficult to read through the quoted text in chronological order.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP3AlK2PeouIeTNHoEQL1YwCggP086cR96Lo52PfmbWOdDH+2STQAn1Wt
iSf1get5RliMiqfMBEtAgVXK
=BCw6
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 23 Sep 2003 05:52:51 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: CGI.pm
Message-Id: <Xns93FF45FC7E2EBsdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"D Borland" <notavailable@nospamplease.com> wrote in
news:11Kbb.860$pz4.2687520@newsfep1-win.server.ntli.net:
> OK, dudes i understand - I'm a lazy git, and i really gotta get my
> head out my arse and in gear!
>
> Maybe not in those exact words, but i understand.
Well, if you choose to be lazy (a good choice, imho), read the manual for
CGI.pm and use that module -- all of the hard work has been done for you.
If you choose not to be lazy, by all means, redo all the work yourself.
:-)
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP3Al/WPeouIeTNHoEQKo3QCfUlw/c6CGmZnah0NtUwfBwrIc3YwAmgMP
YF4EM2nq1JkXUOlkhkJQozFn
=0cOj
-----END PGP SIGNATURE-----
------------------------------
Date: 23 Sep 2003 08:03:28 -0700
From: newsbot@sbcglobal.net (C. Olive)
Subject: Classic ASP HTML Templates like Perl's HTML::Template?
Message-Id: <a813a9a.0309230703.50c5b7e9@posting.google.com>
Sorry to ask for ASP help in a Perl group, but Perl people are the
only ones that are going to know what in the world I'm talking about
by way of Perl comparisions...
I'm stuck doing development work in VBScript and ASP. Yuck.
Previously I've always been able to do ASP work in PerlScript and so
I've always been able to bring the power of Perl (and CPAN modules)
into the ASP environment, but not at this gig.
I'm sorely missing the power of HTML::Template (which I actually used
in ASP/PerlScript). Do any of you Perl hackers out there that have
been pressed into a similiar spot (eg. having to do ASP work) know of
a free ASP templating system that works like Perl's HTML::Template?
I'm desparate. It's twice the work in Classic ASP to use ASP as is
not to mention having to code in VBScript (how do people stomach this
stuff, I wonder?)... Hopefully some Perl person has crossed this
bridge and knows what I'm talking about.
Thanks,
Chris
-----
Chris Olive
chris [I'm at] technologEase [dot] com
http://www.technologEase.com
(pronounced "technologies")
------------------------------
Date: Tue, 23 Sep 2003 12:13:39 +0200
From: udoline <udo@lipsia.de>
Subject: different encoding datastream; if using different (file/socket) descriptoren
Message-Id: <bkp6cj$3ti97$1@ID-26126.news.uni-berlin.de>
hello all,
precondition:
* linux redhat 9.0
* perl, v5.8.0
strange problem:
different process handling between encoding the data stream in the
file-descriptor and in the socket-descriptor (connecton via sybase-driver)
in perl ?
if I run my program with pragma "encoding" then I will got different
encoding datas between SOCKET and STDOUT
eg:
perl -Mencoding="iso 8859-1" -I lib/modules -I.
~/devel/test_unicode/perl/test_unicode_dbconnection.pl
# output to STDOUT (file-descriptor) OK
test db connection (user=siteadmin)... successfull.
INSERT INTO test VALUES( '[0] ä ö ü ß Ä Ö Ü', '[0] Ä Ö Ü ß ä ö ü' ) [0]
# output to SOCKET (socket-descriptor) FALSE
sql statment select ... ERROR not my inserted values found
[0] result from sybase-DB:
col. key1 =<<[0] Ã? ö Ã? Ã
à Ã>>
[0] result from sybase-DB:
col. value=<<[0] Ã
à à Ã
what can I do ?
please help, ThanX.
--
v.g.,
udoline alias udo@lipsia.de
------------------------------
Date: Tue, 23 Sep 2003 13:38:22 GMT
From: mooseshoes <mooseshoes@gmx.net>
Subject: Re: for; while loop interations
Message-Id: <i1Ybb.2$aq6.225467@newssvr21.news.prodigy.com>
<snip>
> What difference does it make ?
<<< I didn't see ">=" listed as a valid operator choice in "Programming
Perl" and I thought that perhaps the "=" was being ignored which would
result in identical results.
Moose
------------------------------
Date: 23 Sep 2003 13:44:55 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: for; while loop interations
Message-Id: <Xns93FF5A6B159E3ebohlmanomsdevcom@130.133.1.4>
Jayaprakash Rudraraju <prakashREMOVE@CAPITALSece.arizona.edu> wrote in
news:Pine.GSO.4.50.0309222054050.19064-100000@shellfish.ece.arizona.edu:
>
> Hi,
>
> The following two snippets of code are iterating the while loop same
> number of times. I am not able to comprehend the reason. Thanks in
> advance for your explanations.
>
> $intv = 1.1;
> while ($intv > 0.4) {
> print "$intv\n";
> $intv -= 0.1
> }
>
> $intv = 1.1;
> while ($intv >= 0.4) {
> print "$intv\n";
> $intv -= 0.1
> }
Never use fractional floating-point values as loop counts, or in any other
case where an exact comparison is required. This is actually a basic
principle of computing, independent of what programming language you're
using. Your problem here is that 0.1 doesn't have an exact representation
as a binary fraction, just as 1/3 doesn't have an exact representation as a
(finite length) decimal fraction.
The basic rule here is that floating-point numbers are not real numbers in
the mathematical sense and cannot be expected to behave like them (for
example, floating-point addition is not always associative). There's a
whole branch of mathematics, numerical analysis, that's devoted to finding
ways to minimize the effects of this unpleasant truth.
------------------------------
Date: Tue, 23 Sep 2003 14:55:07 +0200
From: "David Mills" <mills_nospam_@free.fr>
Subject: Re: Form problems, post method yeilds 0 at end of values
Message-Id: <pan.2003.09.23.12.55.05.613407@free.fr>
> Do this instead:
>
> use CGI;
> my $q = new CGI;
> foreach my $p ($q->param)
> {
> print "[$p] => [", $q->param($p), "]<br />\n";
> }
>
> and see if those zeroes are still there. If so, they came in from the
> form submission, and are not the fault of your program.
Thanks, I'll try it, as for the example, it was much cleaner when I got
it, but as I started experimenting because of the problem I had, it got
messed up a bit.
Thanks again
David Mills
>
> - --
> Eric
> $_ = reverse sort $ /. r , qw p ekca lre uJ reh
> ts p , map $ _. $ " , qw e p h tona e and print
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBP29QcmPeouIeTNHoEQICeACg3aRlw3wpuBCj+qUgKZ0eT0GX9rkAoLEt
> RfupQUyWFvruaRKK6hYt5R7f
> =eHYM
> -----END PGP SIGNATURE-----
------------------------------
Date: Tue, 23 Sep 2003 15:08:07 +0200
From: "David Mills" <mills_nospam_@free.fr>
Subject: Re: Form problems, post method yeilds 0 at end of values
Message-Id: <pan.2003.09.23.13.08.07.136123@free.fr>
On Tue, 23 Sep 2003 14:55:07 +0200, David Mills wrote:
>
>> Do this instead:
>>
>> use CGI;
>> my $q = new CGI;
>> foreach my $p ($q->param)
>> {
>> print "[$p] => [", $q->param($p), "]<br />\n";
>> }
>>
>> and see if those zeroes are still there. If so, they came in from the
>> form submission, and are not the fault of your program.
> Thanks, I'll try it, as for the example, it was much cleaner when I got
> it, but as I started experimenting because of the problem I had, it got
> messed up a bit.
>
Right, they're still there, so I'll have to look else where for the
problem, thanks again to all who helped.
David Mills
------------------------------
Date: Tue, 23 Sep 2003 13:01:14 GMT
From: f_baggins80@hotmail.com (Helgi Briem)
Subject: Re: how to find the biggest ????
Message-Id: <3f7043c0.680145557@News.CIS.DFN.DE>
On Tue, 23 Sep 2003 16:16:12 +0800, "mkl" <mkl.tw@ttt.com> wrote:
>If I have a file ,named txt
>
>###############
>a (298:298) (9:9)
>b (2:2)
>c (3:3)
>d (5:5)
>############################
>
>
>how do i select the biggest one and print ?
Biggest? Which one is biggest? Is d bigger than a?
(298:298) bigger than (9:9). Which values do you wish
to compare?
--
Helgi Briem hbriem AT simnet DOT is
Excuse the munged address. My last
e-mail address was killed by spammers.
------------------------------
Date: 23 Sep 2003 07:04:44 -0700
From: c_j_marshall@hotmail.com (Chris Marshall)
Subject: Re: how to find the biggest ????
Message-Id: <cb9c7b76.0309230604.43d0fc3e@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bkp11r$aa8$2@mamenchi.zrz.TU-Berlin.DE>...
> mkl <mkl.tw@ttt.com> wrote in comp.lang.perl.misc:
> > If I have a file ,named txt
> >
> > ###############
> > a (298:298) (9:9)
> > b (2:2)
> > c (3:3)
> > d (5:5)
> > ############################
> >
> >
> > how do i select the biggest one and print ?
>
> The biggest what?
>
> Someone is going to suggest sorting the items and taking the last one.
> That's inefficient.
>
Why don't you sort it and then...oh.
------------------------------
Date: Tue, 23 Sep 2003 10:07:27 -0400
From: "Rodney" <NoSpamPlease@bellsouth.net>
Subject: How to return an HTML page from a Perl script ?
Message-Id: <ZpYbb.20243$an.644@bignews6.bellsouth.net>
1. I want to have a ahref link, on an HTML page, point to a PERL script.
2. The Perl script will open an existing HTML document and change some of
its content.
3. After altering the HTML document, I want it to be returned to the Web
Client.
I don't want to re-write the entire HTML document with in the PL script
(because then the HTML document can not be easily edited using an HTML
editor). I only want to change certain content then return the document to
the client.
How do I do that?
The PERL script changes the document.... but then it doesn't "return" it ??
Thanks,
--
...
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney
------------------------------
Date: Tue, 23 Sep 2003 14:12:01 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: How to return an HTML page from a Perl script ?
Message-Id: <3f7054ae$1@bandit2.georgetown.edu>
Rodney wrote:
> 1. I want to have a ahref link, on an HTML page, point to a PERL script.
> 2. The Perl script will open an existing HTML document and change some of
> its content.
> 3. After altering the HTML document, I want it to be returned to the Web
> Client.
Read up on the redirect method in the CGI.pm documentation
(http://stein.cshl.org/WWW/software/CGI/#header is a good place to start).
------------------------------
Date: 23 Sep 2003 14:17:22 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: How to return an HTML page from a Perl script ?
Message-Id: <Xns93FF686C89CEFasu1cornelledu@132.236.56.8>
"Rodney" <NoSpamPlease@bellsouth.net> wrote in
news:ZpYbb.20243$an.644@bignews6.bellsouth.net:
> 1. I want to have a ahref link, on an HTML page, point to a PERL
> script. 2. The Perl script will open an existing HTML document and
> change some of its content.
> 3. After altering the HTML document, I want it to be returned to the
> Web Client.
HTML:: Template can help: http://html-template.sourceforge.net/
Sinan.
------------------------------
Date: Tue, 23 Sep 2003 13:41:18 GMT
From: "Eric McDaniel" <netnews1@mcdanielhome.com>
Subject: Net::POP3->new() fails in PerlApp compiled script
Message-Id: <24Ybb.553105$YN5.373571@sccrnsc01>
This may be a question for ActiveState support, but just in case anyone out
there knows what the problem is...
My call to Net::POP3->new() works fine when run through the perl
interpreter, but fails when I compile the script with PerlApp and run it. My
system is Windows 2000, ActiveState Perl 5.8.0 build 806, PerlApp 5.2.0
build 520.
Here is the script:
##############################################################
#!perl -w
use strict;
use Net::POP3;
my $p = Net::POP3->new('mail.mydomain.com', Debug=>99)
or die('Server connection error');
##############################################################
The command'perl pop3.pl' yields this (successful) output:
Net::POP3: Net::POP3(2.23)
Net::POP3: Net::Cmd(2.21)
Net::POP3: Exporter(5.566)
Net::POP3: IO::Socket::INET(1.26)
Net::POP3: IO::Socket(1.27)
Net::POP3: IO::Handle(1.21)
Net::POP3=GLOB(0x1d524ac)<<< +OK X1 NT-POP3 Server mail013.readyhosting.com
(IMail 7.10 2193398-16)
Net::POP3=GLOB(0x1d524ac)>>> RSET
Net::POP3=GLOB(0x1d524ac)<<< +OK
Net::POP3=GLOB(0x1d524ac)>>> QUIT
Net::POP3=GLOB(0x1d524ac)<<< +OK POP3 Server saying Good-Bye
However, when I compile it with PerlApp ('perlapp pop3.pl') and run the
resulting pop3.exe, it dies:
Server connection error at pop3.pl line 7.
Any ideas?
Thanks.
-Eric
------------------------------
Date: Tue, 23 Sep 2003 06:00:05 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Perl: how to stop users from executing commands from browser
Message-Id: <Xns93FF473682841sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
qasim@ti.com (Nick) wrote in
news:9d603421.0309221508.5ba5c9fb@posting.google.com:
> I'm working on an HTML file that calls cope of Perl scripts with
> parameters.
> If you take your cursor over to the link, you can see the command that
> will be send to the perl script and at this point user can modify that
> and execute it from web browser. How can i prevent this from
> happening?????
> Anyway to block users from executing any commands from web browser????
I am not sure what you mean by "cope of". Maybe "a couple of"?
You also are using the word "command" in a very fuzzy manner. Exactly what
do you mean by "command"? URL? CGI script name? Perl operators and/or
code? Shell commands?
If you require the user to click on some link or button in order to perform
some action, there is no way to prevent the user from seeing what is the
underlying data the browser will send to the server.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP3Anr2PeouIeTNHoEQK93ACeOF4+6WumqCuMfrs/uP/8PdBwWdQAoMlE
yAnz40IVcJEHeVqqbQIwwsG3
=cBr9
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 23 Sep 2003 05:44:21 -0500
From: "Terry L. Ridder" <terrylr@blauedonau.com>
Subject: Re: read-only flag
Message-Id: <bkp866$45a3j$1@ID-206651.news.uni-berlin.de>
kielhd wrote:
> Hi NG,
> I would like to access a cd-rom and read the mp3-tags of the mp3-files
> on the cd.
> My problem seems to be that the files on the cd have a read-only flag.
> The script gives me the following message:
>
> Can't open E:\Bush - Razorblade Suitcase\02 - Greedy Fly.mp3:
> Permission denied at C:/Perl/site/lib/MP3/ID3v1Tag.pm line 83.
>
> The modul I am using looks like this around line 83 :
>
> 76 ## Constructor for Object of Module
> 77 sub new {
> 78 my($class,$mp3_file,$readonly) = @_;
> 79 my $self = {};
> 80 $readonly = 0 unless defined($readonly);
> 81 $self->{FileHandle} = new IO::File;
> 82 if( -w $mp3_file || !$readonly) {
> 83 $self->{FileHandle}->open("+<${mp3_file}") or (warn("Can't
> open ${mp3_file}: $!") and return undef);
why are you attempting to open the mp3_file read/write if you
clearly know it is read only?
perldoc perlopentut
line 83 should be:
&self-{FileHandle}->open("<${mp3_file}") or (warn("Can not open
${mp3_file}: $!") and return undef);
> 84 $self->{readonly} = 0;
> 85 } else {
> 86 $self->{FileHandle}->open("<${mp3_file}") or (warn("Can't open
> ${mp3_file}: $!") and return undef);
> 87 $self->{readonly} = 1;
> 88 }
> 89 $self->{filename} = $mp3_file;
> 90 $self->{tag} = ();
> 91 bless($self, ref $class || $class || $DefaultClass);
> 92 my $initialized = $self->init();
> 93 return $self;
> 94 }
>
> Can somebody help me?
> TIA, Henning
--
terry l. ridder ><>
postmaster at blauedonau.com
------------------------------
Date: Tue, 23 Sep 2003 06:14:15 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: read-only flag
Message-Id: <Xns93FF499CF5D8Csdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
kielhd@freenet.de (kielhd) wrote in
news:10a4173d.0309230155.b3900cb@posting.google.com:
> Hi NG,
> I would like to access a cd-rom and read the mp3-tags of the mp3-files
> on the cd.
> My problem seems to be that the files on the cd have a read-only flag.
> The script gives me the following message:
>
> Can't open E:\Bush - Razorblade Suitcase\02 - Greedy Fly.mp3:
> Permission denied at C:/Perl/site/lib/MP3/ID3v1Tag.pm line 83.
...
> Can somebody help me?
> TIA, Henning
Use a different module?
Contact the author of this module and notify him/her of the bug?
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP3ArAWPeouIeTNHoEQIcpQCg4ZuVECk3IZkM2eqkZsDoPbDFl3oAmgPk
xDeVHA6gb6Afs2vtWgnyx9E3
=Tbnr
-----END PGP SIGNATURE-----
------------------------------
Date: 23 Sep 2003 10:35:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: RegExp: Matching
Message-Id: <bkp7ls$fae$1@mamenchi.zrz.TU-Berlin.DE>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in comp.lang.perl.misc:
> On Tue, 23 Sep 2003 03:42:02 +0200,
> Tore Aursand <tore@aursand.no> wrote:
> > Hi!
> >
> > I'm totally stuck with a regular expression. It has actually to do with
> > my Apache configuration (I've posted to alt.apache.configuration), but as
> > regular expressions are quite similar, I hope it's OK to post my question
> > here as well.
>
> I have no idea whether Apache's RE is similar to Perl's. I'll answer
> for Perl RE, and leave it up to you to translate.
>
> If you had crossposted you might have avoided people saying the same
> thing in the two disparate places.
>
> > The problem is that I want to match (inside a <DirectoryMatch> directive)
> > '/var/www/html/test/' and all the subdirectories. However, I _do not_
> > want the regular expression to match on subdirectories which begin with an
> > underscore ('_').
> >
> > Example:
> >
> > /var/www/html/test/ - Match
> > /var/www/html/test - Match
> > /var/www/html/test/2 - Match
> > /var/www/html/test/23/ - Match
> > /var/www/html/test/_foo/ - Do _not_ match
>
>
> I wouldn't normally try to capture this in a single regexp, but I
> guess that's what you're looking for, so...
Indeed. In Perl, this would be a typical case where a single-regex
match is possible, but a combination with other techniques simplifies
things.
> my $dir = "/var/www/html/test";
>
> print "matches" if m#\A^$dir(/[^_]|/?\Z)#;
>
> More readable:
>
> m#
> \A^$dir # Start with the directory
> ( # followed by either
> /[^_] # a slash and a non-underscore character
> | # or
> /?\Z # the end of the string, optionally preceded by slash
> )
> #x;
>
> If Apache doesn't have '\A' and '\Z', you can probably replace them
> with '^' and '$'.
Less readable, but more general:
my $slash = qr{/(?!_)}; # slash not followed by "-"
my $name = qr{[^/]*}; # a string of non-slashes
/^(?:$slash$name)*$/
This matches all full qualified path names where no component name
starts with a "_". For use with apache, the regex must be expanded:
(?-xism:^(?:(?-xism:/(?!_))(?-xism:[^/]*))*$)
Parts of that may still have to go... I'm not sure how much of
"(?...)" syntax apache understands.
Anno
------------------------------
Date: 23 Sep 2003 13:45:02 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: RegExp: Matching
Message-Id: <slrnbn0jiu.qe7.abigail@alexandra.abigail.nl>
Tore Aursand (tore@aursand.no) wrote on MMMDCLXXV September MCMXCIII in
<URL:news:pan.2003.09.23.09.51.36.94475@aursand.no>:
!! On Tue, 23 Sep 2003 02:09:29 +0000, Martien Verbruggen wrote:
!! >> /var/www/html/test/ - Match
!! >> /var/www/html/test - Match
!! >> /var/www/html/test/2 - Match
!! >> /var/www/html/test/23/ - Match
!! >> /var/www/html/test/_foo/ - Do _not_ match
!!
!! > I wouldn't normally try to capture this in a single regexp, but I
!! > guess that's what you're looking for, so...
!!
!! That's right. If I had the chance, which I don't think I have, I need to
!! catch this in _one_ regular expression. Ack! :-)
!!
!! > my $dir = "/var/www/html/test";
!! > print "matches" if m#\A^$dir(/[^_]|/?\Z)#;
!!
!! I don't get this one to work the way intended, either. Even tried it in
!! Perl with a list of possible directory names.
!!
!! It matches on '/var/www/html/test/subdir/_foo/', but it shouldn't.
#!/usr/bin/perl
use strict;
use warnings;
my $re = qr {^/var/www/html/test(?:(?>[^/]+)|/(?!_))*$};
while (<DATA>) {
chomp;
print "$_: ";
print /$re/ ? "matches\n" : "doesn't match\n";
}
__DATA__
/var/www/html/test/
/var/www/html/test
/var/www/html/test/2
/var/www/html/test/23/
/var/www/html/test/_foo/
Running this gives:
/var/www/html/test/: matches
/var/www/html/test: matches
/var/www/html/test/2: matches
/var/www/html/test/23/: matches
/var/www/html/test/_foo/: doesn't match
Abigail
--
perl -we'$;=$";$;{Just=>another=>Perl=>Hacker=>}=$/;print%;'
------------------------------
Date: 23 Sep 2003 06:06:09 -0700
From: robert@nrc.net (Robert)
Subject: Re: some proxies post and some won't with lwp
Message-Id: <22d0e990.0309230506.598448fb@posting.google.com>
my bad for not researching more. The official RFC 2616 says the
following: "The server refuses to accept the request without a defined
Content-Length. The client MAY repeat the request if it adds a valid
Content-Length header field containing the length of the message-body
in the request message."
So I added this:
$request->header('content-length' => $content_length);
-----------
Gregory
1. I DID ask a question about Perl, (ahem... see above Perl solution).
2. Obviously years programming don't account for knowledge. It shows
great arrogance and greater ignorance claiming to know it all.
3. I didn't ask for what many Perl programmers use. Especially one
that can't anwser my question.
4. If you want to flame people for wanting answers, maybe you should
understand the questions?
Gregory Toomey <nospam@bigpond.com> wrote in message news:<3319830.XxEqFPZClK@gregs-web-hosting-and-pickle-farming>...
> It was a dark and stormy night, and Robert managed to scribble:
>
> > Then maybe you can tell me if there's a way with perl that i can solve
> > this problem?
>
>
> 1. If you ask a question in a Perl newsgroup, make sure it relates to Perl. The question you asked didn't have anything to do with Perl.
>
> 2. Many Perl programmers don't use cgi at all. I didn't have a clue what you were talking about, and I have been programming cgi for 8 years.
>
> gtoomey
------------------------------
Date: Tue, 23 Sep 2003 15:35:46 +0100
From: "Bigus" <someone@somewhere.com>
Subject: Re: splitting lines
Message-Id: <bkplnu$jms@newton.cc.rl.ac.uk>
"Trent Curry" <tcurrey@no.no.no.i.said.no> wrote in message
news:bknh7a$rtb$1@news.astound.net...
> D Borland wrote:
> > "Bigus" <bigus_34@yahoo.co.uk> wrote in message
> > news:QbGbb.1792$jJ3.27457@newsfep4-glfd.server.ntli.net...
> >>
> >> "Bob Smith" <bobsmith@jippii.fi> wrote in message
> >> news:3F6F2625.B949AE9@jippii.fi...
> >>> hi
> >>> how to split text into lines?
> >>> I have in a db whitespace delimited words forming chapters in one
> >>> field, and I want to nicely put it on the page with max 30 or so
> >>> characters per paragraph, after that line breaks should occur,
> >>
> >> I take it you mean 30 characters per line rather than paragraph?
> >>
> >> If so, try something like this:
> >>
> >> @lines = $dbtext =~ /(.{30}\S*)/g;
> >> foreach(@lines)
> >> {
> >> $_ =~ s/^\s+//;
> >
> > can't that be typed just as s/^\s+//; not $_ =~ s^\s+//;
>
> Yes it can, since s/ (a substitution op) with no lhs implies using $_;
That's interesting.. I never knew that!
Bigus
------------------------------
Date: 23 Sep 2003 08:00:20 -0700
From: g_klinedinst@hotmail.com (G Klinedinst)
Subject: Re: Stupid perl regexp question
Message-Id: <168f035a.0309230700.2c4b7b05@posting.google.com>
Thank you all for your help. I have learned a number of different ways
to do this but more importantly I think I understand why is wasn't
working in the first place.
It sounds like the {n} operator means to look for n number of
consecutive "/" strings which can occur any number of times in the
string, instead of what I had imagined it meant.
Changing the delimeter helps a bunch, thanks to all who made that
suggestion. Also that tr/// trick where it returns the number of
characters translated is great!
G. Klinedinst
------------------------------
Date: Tue, 23 Sep 2003 05:34:53 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Using variables in RegEx statements?
Message-Id: <Xns93FF42F0D3213sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Rodney" <NoSpamPlease@bellsouth.net> wrote in news:YmKbb.12719$iO.1221
@bignews5.bellsouth.net:
> Here's an example of my code so far... it simply doesn't work ????
Let me guess: You're the kind of person who takes his car to the repair
shop and says, "My car doesn't work -- what's wrong with it????", right?
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP3AhxGPeouIeTNHoEQJfaQCeIq8q5lyng+up2grrfrgjflKBBdwAnAgC
JASt+EYr9+goZAQ6WlM+pk63
=1CX9
-----END PGP SIGNATURE-----
------------------------------
Date: 23 Sep 2003 07:47:46 -0700
From: nospam_timur@tabi.org (Timur Tabi)
Subject: Re: WWW::Mechanize click() returns "Unexpected field value"
Message-Id: <53bb806a.0309230647.3b8b3173@posting.google.com>
Bart Lateur <bart.lateur@pandora.be> wrote in message news:<timumvsta2kijo78nnk9tfei2eaqhnsk1o@4ax.com>...
> says to me that you don't seem to have a form selected. In other words:
> I doubt if there's a form in that page. Try
>
> $agent->form(1);
>
> before calling field(). See if it complains. If it doesn't, you should
> try to get a list of fields that are in that form, though I'm not sure
> how you can do that.
Thanks for the idea. Unfortunately, it didn't help:
Unexpected field value
http://w3.reserve.ibm.com/Reserve/ReserveLogon-3.htm at
/usr/lib/perl5/vendor_perl/5.6.1/HTTP/Headers.pm line 256
HTTP::Headers::_header('HTTP::Headers=HASH(0x846bbb0)',
'Referer', 'http://w3.reserve.ibm.com/Reserve/ReserveLogon-3.htm')
called at /usr/lib/perl5/vendor_perl/5.6.1/HTTP/Headers.pm line 150
HTTP::Headers::header('HTTP::Headers=HASH(0x846bbb0)') called
at (eval 15) line 1
HTTP::Message::__ANON__('HTTP::Request=HASH(0x846bb50)',
'Referer', 'http://w3.reserve.ibm.com/Reserve/ReserveLogon-3.htm')
called at /usr/lib/perl5/site_perl/5.6.1/WWW/Mechanize.pm line 1045
WWW::Mechanize::request('WWW::Mechanize=HASH(0x812feb8)',
'HTTP::Request=HASH(0x846bb50)') called at
/usr/lib/perl5/site_perl/5.6.1/WWW/Mechanize.pm line 515
WWW::Mechanize::click('WWW::Mechanize=HASH(0x812feb8)') called
at /root/bin/reserve.pl line 30
Here's the code in Headers.pm:
if (defined($val)) {
my @new = ($op eq 'PUSH') ? @old : ();
if (!ref($val)) {
push(@new, $val);
} elsif (ref($val) eq 'ARRAY') {
push(@new, @$val);
} else {
Carp::croak("Unexpected field value $val"); [line 256]
}
$self->{$lc_field} = @new > 1 ? \@new : $new[0];
}
I tried adding the line "print $val" to see what $val was, but that
just caused a whole bunch of errors in other parts of Headers.pm,
which completely confused me.
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5549
***************************************