in reply to Reading multiple lines from text file

You can use the flip-flop operator:
perl -ne 'print if / dev$/ .. / manage$/' < file

but it would only print the first "manage" line. To get all of them, you can use several flag variables that tell you where you are:

perl -ne '$in = 1 if / dev$/; $last_lines = 1 if / manage$/; $stop = 1 if $last_lines && ! / manage$/; print if $in && ! $stop; ' < file
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Reading multiple lines from text file
by newperlbie (Acolyte) on Aug 07, 2018 at 20:51 UTC
    thank you. Could you help me how it looks to write inside a file,and not execute on command line
      perlrun shows exactly what -n adds to the script, the rest you can copy verbatim.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Hello newperlbie, and welcome to the Monastery!

      Here’s a variation on choroba’s solution which uses the flip-flop operator and a single flag:

      use strict; use warnings; my $in = 0; while (<DATA>) { if (/ dev$/ .. / manage$/) { $in = 1; print; } elsif ($in && / manage$/) { print; } else { $in = 0; } } __DATA__ aaa23 fgfgdf pppp Released test bbb34 fgfgdf pppp Released test dfsad324 fgfgdf pppp Released test efdewr23 fgfgdf pppp Released dev dsarfew234 fgfgdf pppp skip dev dqewr2321 fgfgdf pppp skip prod sdsw32 fgfgdf pppp Released prod asdw234 fgfgdf pppp Released prod sadw2342 fgfgdf pppp Released qa deww234 fgfgdf pppp Released qa qdrqew234 fgfgdf pppp block qa swd234 fgfgdf pppp Released manage swdq234 fgfgdf pppp Released manage dfwfr43 fgfgdf pppp Released manage drqewr234 fgfgdf pppp Released manage drqewr234 fgfgdf pppp Released qb

      Output:

      15:54 >cd ..\Tests\1901-2000 15:54 >perl 1916_SoPW.pl efdewr23 fgfgdf pppp Released dev dsarfew234 fgfgdf pppp skip dev dqewr2321 fgfgdf pppp skip prod sdsw32 fgfgdf pppp Released prod asdw234 fgfgdf pppp Released prod sadw2342 fgfgdf pppp Released qa deww234 fgfgdf pppp Released qa qdrqew234 fgfgdf pppp block qa swd234 fgfgdf pppp Released manage swdq234 fgfgdf pppp Released manage dfwfr43 fgfgdf pppp Released manage drqewr234 fgfgdf pppp Released manage 15:54 >

      Hope that helps,

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

        Thank You....yes,it helped. Looking for a little variation now, if I need to output only the keys dev,prod,qa,manage and not the entire line? can a little variation here help? or even more,if I am using variables instead of hardcoding, say if (/ $first/../ $last/), how to get only these strings, print and store them into an array(?) which can be traversed later.