perl script to extract lines.

File test.csv in following format

cool dude!
be frank
"jumbo jet","A370"
airbus,from,UK
Boeing,from,US
"fly","with"
whatsup
c ya

Please suggest Perl script to extract lines between"jumbo jet","A370" and "fly","with" and output to file called output.csv
output.csv should be as given below.

airbus,from,UK
Boeing,from,US
BegunixAsked:
Who is Participating?
 
ozoCommented:
perl -ne 'print if (/jumbo jet","A370"/../"fly","with"/)=~/^([2-9]|\d{2,})$/' test.csv  >  output.csv
0
 
BegunixAuthor Commented:
Thanks for the reply.
But instead of one liner code, how to achieve the desired result by reading the file.
open(TXT,"text.csv)
while(<TXT>)
{
...

}

Thanks
0
 
Adam314Commented:
converting ozo's code into a non-one-liner...


open(TXT,"<test.csv") or die "input: $!\n";
while(<TXT>) {
      print if (/jumbo jet","A370"/../"fly","with"/)=~/^([2-9]|\d{2,})$/;
}
close(TXT);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.