in reply to Re^3: How can you check to see if a file handle is already open?
in thread How can you check to see if a file handle is already open?
while(<INPUT>) { chomp $_; if ( $_ =~ m#^(\d+)/(\d+)/(\d+)\s+# ) { my $date = join( '', ( $3, $1, $2) ); if ( ! $file_handles{$date} ) { open($file_handles{$date}, ">>", "$output_dir/$date") +or die "Could not open $date for writing: $!\n"; print { $file_handles{$date} } "$_\n"; } elsif ( defined $file_handles{$date} ) { print { $file_handles{$date} } "$_\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How can you check to see if a file handle is already open?
by alexm (Chaplain) on Jan 17, 2008 at 09:01 UTC |