in reply to Re: Printing different hash elements to different files
in thread Printing different hash elements to different files

Not under strict.pm! You are actually accessing global package variables when you open on a string like that. If you want to make this work, you need to store the filehandles somewhere like this (5.6 on up) example:
my %hash = ( one => "first bit", two => "second bit", ); my %fh; foreach my $file_name (keys %hash) { open (my $fh, ">", $file_name) or die "Could not write to '$file_name': $!"; $fh{$file_name} = $fh; } foreach my $key (keys %hash) { print {$fh{$key}} "$key => $hash{$key}\n"; }
Of course if you've gone this far, then you may want a mapping between keys and file names...