my $file_num = 1; while (<IN>) { if (/^(\d+)\s*$/) { my $count = $1; my $fname = sprintf("new_file%02d.txt", $file_num); open(OUT,">$fname") or die "Cannot open file $fname: $!\n"; for(1..$count){ my $rec = <IN>; print OUT $rec; } close OUT; $file_num++; } else { # ignore the file separator ======= } }
In reply to Re: (jeffa) Re: To regex or not to regex
by abstracts
in thread To regex or not to regex
by mndoci
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |