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


in reply to Re^6: How to extract certain range of text and display it?
in thread How to extract certain range of text and write into another file?

I used $_ but nothing prints out.

Sure it does

$ perl -l snafu $ NAME : corry $$.Inc s d $$.Oc s $$.TO G1 ty n1 EE EE M T1 T2 $$SRU G2 n1 y OO OO M T3 T4 $$SRU .EON

and here is snafu

#!/usr/bin/perl -- use warnings; use strict; my $test; my @words; #~ open(INFO,"<","testing.pl")||die"Can't open file:$!\n"; open(INFO,"<", __FILE__ )||die"Can't open file:$!\n"; chomp (@words=<INFO>); close(INFO); foreach (@words){ if(/^\$ NAME : corry/ .. /\.EON/){ $test=$_; print $test; } } __END__ $ NAME : corry $$.Inc s d $$.Oc s $$.TO G1 ty n1 EE EE M T1 T2 $$SRU G2 n1 y OO OO M T3 T4 $$SRU .EON $ NAME : patrick $$.Inc c d $$.Oc c $$.TO G1 td n3 EE EE M T5 T6 $$SRU G2 n3 y OO OO M T7 T8 $$SRU .EON

Basic debugging checklist , brian's Guide to Solving Any Perl Problem......