in reply to Re: Selecting text between given words (multi-lines (/n) and multiple occurrences)
in thread Selecting text between given words (multi-lines (/n) and multiple occurrences)

First things first: Paladin thx :-)

How do I get the actual data between begin & end in an output file? When I try, the file stays empty.
#----------------------------------------------------------- #!/usr/bin/perl (This code does not work !!!) # # between.pl <output file><input file><begin word><end word> # open (FH_output, ">> $ARGV[0]") or die "Couldn't open file.txt: $!"; open FH_input, "< $ARGV[1]" or die "Couldn't open file.txt: $!"; while (<FH_input>) { if (/^$ARGV[2]$/ .. /^$ARGV[3]$/) { $info = $_ ; print FH_output $info; } } close (FH_input) ; close (FH_output) ;
Thanks,

Firewall (Perl is fun. I'm going to study it some more. But still a long way to go :-)
  • Comment on Re: Re: Selecting text between given words (multi-lines (/n) and multiple occurrences)
  • Download Code