in reply to How to scan a file, find a character string and print from that string to EOF
This doesn't put the line containing DETS01 in either file, so change it if it should.#!/usr/bin/perl -w open INPUT, "target.txt" || die "can't read from target:$!\n"; open OUTPUT1, ">file1.txt" || die "can't write to file1.txt:$!\n"; open OUTPUT2, ">file2.txt" || die "can't write to file2.txt:$!\n"; # # while (<INPUT>) { last if $_ =~ /^DETS01/; print OUTPUT1 "$_\n"; } while (<INPUT>) { print OUTPUT2 "$_\n" } close INPUT; close OUTPUT1; close OUTPUT2;
|
|---|