in reply to How to generate files based on some special character?
my $out_fh; while (<$in_fh>) { if (my ($out_fn) = /^< (.*)/) { open($out_fh, '>', $out_fn) or die("Unable to create file \"$out_fn\": $!\n"); } else { print $out_fh $_; } }
Update: Removed chomp.
Update: Removed unneeded undef $out_fh;.
|
|---|