[27593] in Perl-Users-Digest
Perl-Users Digest, Issue: 9110 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 31 18:05:42 2006
Date: Fri, 31 Mar 2006 15:05:06 -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 Fri, 31 Mar 2006 Volume: 10 Number: 9110
Today's topics:
-e fails sometimes <no@thanks.com>
Re: Find duplicates in a dat file <eflorac@imaginet.fr>
Re: multi-line regular expression help <ces@cescom.com>
Re: multi-line regular expression help <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 31 Mar 2006 21:57:55 +0200
From: Asterbing <no@thanks.com>
Subject: -e fails sometimes
Message-Id: <MPG.1e97a82998548fab9897bc@news.tiscali.fr>
Hello. Under ActivePerl/Apache2/Win2k, sometimes (not everytime) the
file existence test fails while the path is correct.
For example, here sometimes $fileok becomes zéro, while $file exist on
disk in fact.
if (! -e $file){$fileok = 0;}
Is-it a -e stability issue ?
Does the $file syntax should follow some rules (comes from a form and I
don't escape the "\", is that ok ?) ?
Should I go through open rather than -e ?
What do you think about that ?
------------------------------
Date: Fri, 31 Mar 2006 21:31:02 +0200
From: Emmanuel Florac <eflorac@imaginet.fr>
Subject: Re: Find duplicates in a dat file
Message-Id: <pan.2006.03.31.19.31.02.613913@imaginet.fr>
Le Fri, 31 Mar 2006 10:30:03 -0600, Tad McClellan a écrit :
>
> Because then when I can't find a program I remember writing
> a long time ago, I just run the program below to make an
> index of all of my Perl programs.
clever :)
--
Ce qu'il y a d'enivrant dans le mauvais goût c'est le plaisir
aristocratique de déplaire.
C. Baudelaire.
------------------------------
Date: Fri, 31 Mar 2006 19:47:17 GMT
From: Cesar Baquerizo <ces@cescom.com>
Subject: Re: multi-line regular expression help
Message-Id: <9HfXf.5051$x97.9@news-wrt-01.rdc-nyc.rr.com>
Actually looking at both your answers made it clear what my problem was.
I incorrectly assumed that multi-line match had an effect on the
contents of $_.
As my data is on multiple lines and I was only reading in 1 line at a
time, I could never match the regex over multiple lines.
Thanks
Tome wrote:
> I copied and pasted your regex as well as your string and it worked with no problem:
>
> $string = "03/27 MON 07:59A [ 11:59A 12:44P] (b12:45P
> b01:15P) 04:30P 8:00 0:00 0:00";
> print "$&\n" if $string =~ /^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms;
>
> It definitely succeeded in the match and printed it fine. .* will match newlines as long as you
> have /s.
>
> Maybe if you post your code we can find the problem.
>
> ---Tome
>
> On Fri, 31 Mar 2006 16:46:43 GMT, Cesar Baquerizo <ces@cescom.com> wrote:
>
>> Hello,
>>
>> I am having a problem trying to match both of the following strings:
>>
>> 03/23 THU 07:09A (b12:00P b12:30P) 04:30P 8:00 0:00 0:00
>>
>> as well as (embedded newline):
>>
>> 03/27 MON 07:59A [ 11:59A 12:44P] (b12:45P
>> b01:15P) 04:30P 8:00 0:00 0:00
>>
>> The first string always matches, but the second never matches. I've
>> tried different incarnations of the following regex with no success:
>>
>> (/^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms)
>> ^^
>>
>> I was hoping that the above part (.*) would match a newline or anything
>> else in this case and return it in $&.
>>
>> Any help appreciated.
>>
>> Thanks
------------------------------
Date: Fri, 31 Mar 2006 16:44:00 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: multi-line regular expression help
Message-Id: <slrne2rc5g.1jp.tadmc@magna.augustmail.com>
Cesar Baquerizo <ces@cescom.com> wrote:
> I am having a problem trying to match
I'll bet that you are having a problem...
> both of the following strings:
>
> 03/23 THU 07:09A (b12:00P b12:30P) 04:30P 8:00 0:00 0:00
>
> as well as (embedded newline):
>
> 03/27 MON 07:59A [ 11:59A 12:44P] (b12:45P
> b01:15P) 04:30P 8:00 0:00 0:00
... getting both lines into the string that you are matching against.
Just like in the Frequently Asked Question:
perldoc -q line
I'm having trouble matching over more than one line. What's wrong?
> The first string always matches, but the second never matches.
Are you *certain* that the 2nd string contains what you think
it contains?
Did you print it out to see?
> I've
> tried different incarnations of the following regex with no success:
>
> (/^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms)
It works for me...
---------------
#!/usr/bin/perl
use warnings;
use strict;
$_ = '03/27 MON 07:59A [ 11:59A 12:44P] (b12:45P
b01:15P) 04:30P 8:00 0:00 0:00';
if (/^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms)
{ print "it matched\n" }
---------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 9110
***************************************