http://www.perlmonks.org?node_id=870289


in reply to parsing a txt file

while (<>) { s/^/X/ if /marker1/.../marker2/; print; }

Or something along those lines. If you describe your problem better, and what you tried, and where you are having problems, I might give you a better answer.

P.S. what does the title of your question has to do with the rest of the question?

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: get data from the database -CGI
by mjscott2702 (Pilgrim) on Nov 09, 2010 at 15:47 UTC
    I have used the standard "flip-flop" .. operator for similar things, but always had to explicitly exclude the start and end points i.e. marker1 and marker2.

    Does the ... remove the need for this? Is this only for more recent Perl versions (still stuck on 5.8)?

      Why don't you just try it?
      Perl 6 - links to (nearly) everything that is Perl 6.
        Fair enough, so I did, using the following:
        while(<DATA>) { print if (/line1/ ... /line5/); } __DATA__ line1 line2 line3 line4 line5

        Outputs all the lines, including the start and end "markers". So, unless I am doing something wrong, I don't see how this is any different from the .. operator I have used in the past (at least under 5.8)?

        Reason I didn't just try it (which I should have anyway, admittedly) is that I thought myself and others would benefit from a little further explanation.

        Guess it's RTFM time for me...