> im wondering how i can make a subroutine that will return all text > lines between certain marks such as START and STOP: > > text file: > > START > text > is here > and there > is > a > lot of it > STOP > > so i would like to call the subroutine with the arguments START and > STOP (because i may need more starts and stops later) and have the > subroutine return the lines between START and STOP in a $. > > i guess it should be pretty simple, however its out of my reach still :P > > any help will be appreciated :) ! > > martin
Hi Martin, Once upon a time (hmmm, last July) on another list I asked a similar question. Japhy's answer might scramble some grey matter at first, but it works and you might find it useful: >What's a good way to split up the contents of a file into separate arrays? > >########## Ignore ########## >stuff to ignore >########## Preamble ########## >Mary >########## Body ########## >had >a >########## Epilog ########## >little lamb Here's a cool trick: use the $/ variable to change how much Perl reads in when you use <FH>. my (@preamble, @body, @epilog); { local $/ = "\n########## Preamble ##########\n"; <FILE>; # skip everything up to the beginning of the preamble $/ = "\n########## Body ##########\n"; chomp (my $pre_str = <FILE>); # get everything to the end of pre. @preamble = split /\n/, $pre_str; $/ = "\n########## Epilog ##########\n"; chomp (my $bod_str = <FILE>); # get everything to the end of body @body = split /\n/, $bod_str; $/ = undef; # get everything else chomp (my $epi_str = <FILE>); @epilog = split /\n/, $epi_str; } -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]