How's abouts this (pls excuse any syntax errs) .....

my $out1 = "$file1.txt";
my $out2 = "$file2.txt";

open(INPUT, $filename) or die "error: $filename cannot be opened\n";
open(OUT1, ">$out1") or die "error: $out1 cannot be opened for writing\n";
open(OUT2, ">$out2") or die "error: $out2 cannot be opened for writing\n";

my $regex_split_space='\s+';
my $regex_marker='^marker';
my $regex_header='^header';

while (<INPUT>) {    # read file line by line
    next if m/$regex_header/;    # skip if header line
    next if m/$regex_marker/;    # skip if marker line
    if (/^.*?\s\+1\s\+/) {    # true if '1' is sandwiched by 1st & 2nd '\s+'
        print OUT1;
    }
    else {
        if (/^.*?\s\+2\s\+/) {    # true if '2' is sandwiched by 1st & 2nd
'\s+'
            print OUT2;
        }
        else {
            die "saw something other than a 1 or 2 line\n";
        }
    }
}




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to