[29800] in Perl-Users-Digest
Perl-Users Digest, Issue: 1043 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 19 18:19:40 2007
Date: Mon, 19 Nov 2007 15:19:31 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 19 Nov 2007 Volume: 11 Number: 1043
Today's topics:
Regular expression help <benedictmpwhite@gmail.com>
Re: Regular expression help <ben@morrow.me.uk>
Re: Regular expression help <jimsgibson@gmail.com>
Re: Session Cookie Glitch with mod_perl 2.03 and Apache <stratfan@mindspring.com>
Syntax error? What syntax error? Assignment fo default (Mark Richards)
Re: Syntax error? What syntax error? Assignment fo defa <jurgenex@hotmail.com>
Re: Syntax error? What syntax error? Assignment fo defa patriknym@hotmail.com
Re: Syntax error? What syntax error? Assignment fo defa <tadmc@seesig.invalid>
Re: Syntax error? What syntax error? Assignment fo defa <abigail@abigail.be>
Re: Why this file download CGI works with Firefox and f <us@invalid.org>
Re: Why this file download CGI works with Firefox and f <stoupa@practisoft.cz>
Re: Why this file download CGI works with Firefox and f <us@invalid.org>
Re: Why this file download CGI works with Firefox and f <stoupa@practisoft.cz>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 19 Nov 2007 09:33:57 -0800 (PST)
From: Benedict White <benedictmpwhite@gmail.com>
Subject: Regular expression help
Message-Id: <3bedd977-a9d6-45f3-a94d-68d9f2177c19@c29g2000hsa.googlegroups.com>
I need a bit of help cleaning up a mess.
I need to write a regular expression that looks for invalid email
addresses. I know that the email addresses do not contain numerical
charictors or unusual combinations of letters.
What I was hoping for was something that would locate all emails with
say 2 before the at addressed to the domain I am looking after,
example.com.
I tried ^[A-Za-z2._%+-]+@example.com however the 2 is not required.
The numbers could be anywhere in string before the @. It will miss
email addresses with other numbers in them, but will also pick up any
without out. I need to have all with numbers in them, to the
example.com domain.
Then I want to extend it to look for odd combinations of letters, like
xb, which would then have to appear together but anywhere in the
string.
Kind regards
Benedict White
------------------------------
Date: Mon, 19 Nov 2007 18:21:47 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Regular expression help
Message-Id: <rq0915-373.ln1@osiris.mauzo.dyndns.org>
Quoth Benedict White <benedictmpwhite@gmail.com>:
> I need a bit of help cleaning up a mess.
>
> I need to write a regular expression that looks for invalid email
> addresses. I know that the email addresses do not contain numerical
> charictors or unusual combinations of letters.
It would be better to use a module that knows how to parse email
addresses.
It may be better to start with a list of valid address, and proceed from
there; however, this may not be possible.
> What I was hoping for was something that would locate all emails with
> say 2 before the at addressed to the domain I am looking after,
> example.com.
>
> I tried ^[A-Za-z2._%+-]+@example.com however the 2 is not required.
> The numbers could be anywhere in string before the @. It will miss
> email addresses with other numbers in them, but will also pick up any
> without out. I need to have all with numbers in them, to the
> example.com domain.
>
> Then I want to extend it to look for odd combinations of letters, like
> xb, which would then have to appear together but anywhere in the
> string.
Something like
#!/usr/bin/perl
use warnings;
use strict;
use Email::Address;
my $domain = 'example.com';
my $invalid = qr/ \d | xb /x;
my @addrs = qw{
abc%
a@a<foo@bar.org>
foo@bar.org
one2three@example.com
AAxbYY@example.com
user@example.com
};
sub result {
my ($reason) = @_;
warn "$reason\n";
no warnings 'exiting';
next ADDR;
}
ADDR: for my $addr (@addrs) {
my ($parsed) = Email::Address->parse($addr)
or result "invalid address: $addr";
$parsed->original eq $addr
or result "extra gunk around address in '$addr'";
$parsed->host eq $domain
or result "'$addr' not at '$domain'";
$parsed->user =~ $invalid
and result "'$addr' contains a forbidden string";
result "'$addr' is valid";
}
__END__
should work.
Ben
------------------------------
Date: Mon, 19 Nov 2007 11:18:45 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Regular expression help
Message-Id: <191120071118459849%jimsgibson@gmail.com>
In article
<3bedd977-a9d6-45f3-a94d-68d9f2177c19@c29g2000hsa.googlegroups.com>,
Benedict White <benedictmpwhite@gmail.com> wrote:
> I need a bit of help cleaning up a mess.
>
> I need to write a regular expression that looks for invalid email
> addresses. I know that the email addresses do not contain numerical
> charictors or unusual combinations of letters.
>
> What I was hoping for was something that would locate all emails with
> say 2 before the at addressed to the domain I am looking after,
> example.com.
>
> I tried ^[A-Za-z2._%+-]+@example.com however the 2 is not required.
> The numbers could be anywhere in string before the @. It will miss
> email addresses with other numbers in them, but will also pick up any
> without out. I need to have all with numbers in them, to the
> example.com domain.
>
> Then I want to extend it to look for odd combinations of letters, like
> xb, which would then have to appear together but anywhere in the
> string.
This type of question has been asked frequently in the past. See
perldoc -q address
"How do I check a valid mail address?"
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Sun, 18 Nov 2007 19:12:05 -0800 (PST)
From: stratfan <stratfan@mindspring.com>
Subject: Re: Session Cookie Glitch with mod_perl 2.03 and Apache 2.2.6
Message-Id: <fe648631-85e6-40c7-b9ed-243e7cdf7d00@b32g2000hsa.googlegroups.com>
I've managed to solve the mystery so I am posting my findings to help
save others some frustration. The core problem involved the code
retrieving cookie data from the HTTP headers. Many of the examples
for using mod_perl 2.x use the following syntax for retrieving cookies
inside the module used for authentication:
---------------------------------------
my $cookiejar = Apache2::Cookie::Jar->new($r); # where $r is the
Apache2::RequestRec object
my $appcookie = $cookiejar->cookies('MYAPPCOOKIENAME');
---------------------------------------
Unfortunately, the Jar->new() call in the underlying libapreq module
was abandoned in libapreq 2.05 and higher versions. Changes in that
release now rely upon methods in the APR::Request module so the
following steps are required:
1) create a new APR::Request object from the incoming
Apache2::RequestRec passed to the handler
2) test if the APR::Request object successfully parsed the headers of
the incoming HTTP request
3) retrieve a APR::Request::Cookie::Table object via the jar() method
4) retrieve your desired cookie via a get() call in the Table object
The code looks like this:
---------------------------------------
my $aprreq = APR::Request::Apache2->handle($r);
if ($aprreq->jar_status()) {
# if jar_status is non-zero, headers could not be parsed, nothing
to do here
# so just return OK and let the Apache engine handle the request
return $Apache2::Const::OK;
}
my $cookiejar = $aprreq->jar;
my $appcookie = '';
$appcookie = $cookiejar->get('MYAPPCOOKIENAME');
---------------------------------------
This code would go in the handler() method of the PERL module you
reference in the PerlAuthenHandler configuration of the Apache server
configuration.
I still have no idea why the old code with the references to broken
calls in libapreq worked on ANY browser clients but the code is now
working for my intended client audience.
stratfan
------------------------------
Date: 18 Nov 2007 16:36:04 GMT
From: markmark@lycos.com (Mark Richards)
Subject: Syntax error? What syntax error? Assignment fo default values?
Message-Id: <474069f4$0$16665$9b4e6d93@newsspool3.arcor-online.net>
When I run the following piece of code:
if !defined( $ARGV[ 1 ] ) {
if !defined( $ARGV[ 0 ] ) {
$mypath = '\\'; }
mydepth = 1; }
then I am getting the following error:
syntax error at du_cb.pl line 19, near "if !"
Execution of du_cb.pl aborted due to compilation errors.
Where is the syntax error? Even if I replace ' by " it does not work.
As you can imagine I want to assign default values if I don't pass special, individual parms.
How can I do this otherwise?
Mark
------------------------------
Date: Sun, 18 Nov 2007 16:40:00 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Syntax error? What syntax error? Assignment fo default values?
Message-Id: <AVZ%i.2696$Jy1.1354@trndny02>
Mark Richards wrote:
> When I run the following piece of code:
>
> if !defined( $ARGV[ 1 ] ) {
> if !defined( $ARGV[ 0 ] ) {
> $mypath = '\\'; }
> mydepth = 1; }
>
> then I am getting the following error:
>
> syntax error at du_cb.pl line 19, near "if !"
> Execution of du_cb.pl aborted due to compilation errors.
From "perldoc perlsyn":
The following compound statements may be used to control flow:
if (EXPR) BLOCK
[...]
> Where is the syntax error?
You are missing the mandatory paranthesis around the condition.
jue
------------------------------
Date: Sun, 18 Nov 2007 08:43:07 -0800 (PST)
From: patriknym@hotmail.com
Subject: Re: Syntax error? What syntax error? Assignment fo default values?
Message-Id: <b62e0c91-819e-4f67-b496-a66f92dcbd78@v4g2000hsf.googlegroups.com>
On 18 Nov, 16:36, markm...@lycos.com (Mark Richards) wrote:
> When I run the following piece of code:
>
> if !defined( $ARGV[ 1 ] ) {
> if !defined( $ARGV[ 0 ] ) {
> $mypath = '\\'; }
> mydepth = 1; }
>
> then I am getting the following error:
>
> syntax error at du_cb.pl line 19, near "if !"
> Execution of du_cb.pl aborted due to compilation errors.
>
> Where is the syntax error? Even if I replace ' by " it does not work.
>
> As you can imagine I want to assign default values if I don't pass special, individual parms.
>
> How can I do this otherwise?
>
> Mark
if ( !defined $ARGV[ 1 ] ) {
if ( !defined $ARGV[ 0 ] ) {
$mypath = '\\'; }
$mydepth = 1; }
/Patrik
------------------------------
Date: Sun, 18 Nov 2007 17:01:08 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Syntax error? What syntax error? Assignment fo default values?
Message-Id: <slrnfk0rsh.nhl.tadmc@tadmc30.sbcglobal.net>
Mark Richards <markmark@lycos.com> wrote:
> $mypath = '\\'; }
You can probably use sensible directory separators instead:
$mypath = '/'; }
Forward slashes work fine on Windows (they don't work fine only
in the Windows "shell").
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: 19 Nov 2007 09:48:14 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Syntax error? What syntax error? Assignment fo default values?
Message-Id: <slrnfk2muu.9tf.abigail@alexandra.abigail.be>
_
Mark Richards (markmark@lycos.com) wrote on VCXCII September MCMXCIII in
<URL:news:474069f4$0$16665$9b4e6d93@newsspool3.arcor-online.net>:
** When I run the following piece of code:
**
** if !defined( $ARGV[ 1 ] ) {
** if !defined( $ARGV[ 0 ] ) {
** $mypath = '\\'; }
** mydepth = 1; }
**
** then I am getting the following error:
**
** syntax error at du_cb.pl line 19, near "if !"
I guess you're trying to run perl6 code using a perl5 interpreter.
In perl5, we do write the expression following the 'if' inside parenthesis.
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20071119
------------------------------
Date: Sat, 17 Nov 2007 23:56:47 +0100
From: Us <us@invalid.org>
Subject: Re: Why this file download CGI works with Firefox and fails with IE ?
Message-Id: <MPG.21a99019da939324989978@news.tiscali.fr>
In article <fhmujv$2i09$1@ns.felk.cvut.cz>, stoupa@practisoft.cz says...
> This work for me
>
Interesting, because it doesn't work on my side (I've tried under
Windows too, to be on same case as yours).
I've tried a first time with the path with c:\... as you, and a second
time changing to something in the web space like this (w/o some typo
found) :
#!/usr/bin/perl
use strict;
my $file='../../htdocs/test/test.zip';
my $name=$file;
$name=~s/^.+\/(.+)$/$1/;
my $size=(stat $file)[7];
binmode STDOUT;
print "Content-Type: application/zip\n",
"Accept-Ranges: bytes\n",
"Cache-Control: no-cache, no-store, no-transform, must-revalidate\n",
"Content-disposition: attachment; filename=$name\n",
"Content-Length: $size\n\n";
my $buf;
open(F,"<$file");
binmode F;
read(F,$buf, 1024);
while ($buf)
{
print $buf;
read(F,$buf, 1024);
}
close F;
And it continue do do the same : IE start download-dlg, then search for
info and sto with an error saying "Internet Explorer cannot download
download_test.pl from www.mysite..."
I've tried with a lot of HTTP headers now and not any solution :-(
------------------------------
Date: Sun, 18 Nov 2007 15:45:16 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Why this file download CGI works with Firefox and fails with IE ?
Message-Id: <fhpjb2$osu$2@ns.felk.cvut.cz>
Us wrote:
> In article <fhmujv$2i09$1@ns.felk.cvut.cz>, stoupa@practisoft.cz
> says...
>> This work for me
>>
>
> Interesting, because it doesn't work on my side (I've tried under
> Windows too, to be on same case as yours).
>
> I've tried a first time with the path with c:\... as you, and a second
> time changing to something in the web space like this (w/o some typo
> found) :
>
> #!/usr/bin/perl
> use strict;
> my $file='../../htdocs/test/test.zip';
Are you sure that this is a system path to file? You can't to use URL path.
For example (on unix) if your file test.zip is stored in
/var/www/htdocs/test/ then you must use
my $file='/var/www/htdocs/test/test.zip';
My second advice is to use .cgi extension instead of .pl for web perl
scripts and my third advice is to use slash / instead of backslash \. This
work on all operating systems (*nix, Win, Mac).
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Sun, 18 Nov 2007 22:37:06 +0100
From: Us <us@invalid.org>
Subject: Re: Why this file download CGI works with Firefox and fails with IE ?
Message-Id: <MPG.21aacef1e2110945989980@news.tiscali.fr>
In article <fhpjb2$osu$2@ns.felk.cvut.cz>, stoupa@practisoft.cz says...
> Are you sure that this is a system path to file? You can't to use URL path.
> For example (on unix) if your file test.zip is stored in
> /var/www/htdocs/test/ then you must use
>
> my $file='/var/www/htdocs/test/test.zip';
I think you can use indifferently full qualified path or relative one
from root or the script itself (what I've done here)
>
> My second advice is to use .cgi extension instead of .pl for web perl
> scripts
An usual to remember what's in Perl and what's not :)
>and my third advice is to use slash / instead of backslash \. This
> work on all operating systems (*nix, Win, Mac).
>
It's what I do most of the time ;)
------------------------------
Date: Mon, 19 Nov 2007 04:03:47 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Why this file download CGI works with Firefox and fails with IE ?
Message-Id: <fhqvn0$1f5g$1@ns.felk.cvut.cz>
Us wrote:
> In article <fhpjb2$osu$2@ns.felk.cvut.cz>, stoupa@practisoft.cz
> says...
>> Are you sure that this is a system path to file? You can't to use
>> URL path. For example (on unix) if your file test.zip is stored in
>> /var/www/htdocs/test/ then you must use
>>
>> my $file='/var/www/htdocs/test/test.zip';
>
> I think you can use indifferently full qualified path or relative one
> from root or the script itself (what I've done here)
>
Yes, if course. I wanted to accent that must be used system path instead of
"http path" ;-)
But be careful that perl script is in some directory but can be run (by
Apache) from other directory. In this case the relative path is not good
idea. I'm used to use some "our" variable where I have stored absolute path
to web root directory and all other paths I create from this variable. For
example:
# virtual server for domain mydomain.com
our $webroot = '/var/www/mydomain/home/';
...
my $downloadpath = $webroot . 'download/';
# virtual server for domain otherdomain.com
our $webroot = '/var/www/otherdomain/home/';
...
my $downloadpath = $webroot . 'download/';
I think you understand me ;-)
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
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 V11 Issue 1043
***************************************