[32241] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3506 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 25 03:09:19 2011

Date: Sun, 25 Sep 2011 00:09:04 -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           Sun, 25 Sep 2011     Volume: 11 Number: 3506

Today's topics:
    Re: Question about range of Lines <hjp-usenet2@hjp.at>
    Re: Question about range of Lines <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 25 Sep 2011 08:42:35 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Question about range of Lines
Message-Id: <slrnj7tjar.b90.hjp-usenet2@hrunkner.hjp.at>

On 2011-09-19 19:39, sln@netherlands.com <sln@netherlands.com> wrote:
> On Mon, 19 Sep 2011 11:08:46 +0200, Mauro <dba1_no_spam@csi.it> wrote:
>
>>> Another solution which avoids the range operator:
>>>
>>> perl -e '$/ = undef; $s =<>; print $s =~ /^(Tuesday.*?)^Friday/sm;' t1
>>
>>Thank you, it is a nice idea ( but for too much long files, perhaps ).
>>
>
> "but for too much long files, perhaps"
>
> I would give this credibility if you can show some code that
> guarantees there is a 'Friday'.

True. My code behaves differently than the original if the Friday is
missing. But maybe a range which doesn't end with Friday is malformed
and should be omitted. Mauro didn't specify, but this is definitely
something he would have to consider.

I was assuming that "Tuesday" and "Friday" are just arbitrary begin and
end markers and that lines don't have a natural order. But what if they
have? Given the input:

Monday
Wednesday
Thursday
Friday
Saturday
Sunday

should it print 

Wednesday
Thursday

?

Then neither the range operator nor the regexp will work (both rely on 
"Tuesday" being there) and you would need a different approach (like
converting weekdays to numbers and then checking whether the number is
in [2, 5)).

	hp


------------------------------

Date: Sun, 25 Sep 2011 08:46:05 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Question about range of Lines
Message-Id: <slrnj7tjhd.b90.hjp-usenet2@hrunkner.hjp.at>

On 2011-09-20 13:31, Mauro <dba1_no_spam@csi.it> wrote:
> I had expressed that doubt ( about long files ) since, if I understand 
> correctly, that solution read the whole file in memory.

Yes, it does. Whether that's a problem depends on how long the file is,
how much memory you have and what you are doing with the file. Caveat
emptor!

	hp


------------------------------

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3506
***************************************


home help back first fref pref prev next nref lref last post