in reply to Concatenating lines found between two words
Your failure to specify exactly what you mean (are the words on lines by themselves as delimiting lines? can they be anywhere? do you want to include the delimiting words/lines?) means I can freely assume you meant the following case: The two words are on lines by themselves and you want to include them (and for the present example, the words are START and STOP), and we'll read whatever file was passed on the command line:
#!/usr/bin/perl -w use strict; my $string = ''; while(<>){ $string .= $_ if /^START$/ .. /^STOP$/; } print $string; __END__
If your specs are different you'll have to adjust accordingly (ie, you can strip off the delimiting words easily enough, but if your file has multiple cases of such target regions, you'll get them all in a single string with the above).
|
|---|