in reply to hash element as file handle

Change that to:

my %files; while ( <DATA> ) { next unless /^(\w+): (\d) (\w+)/; unless ( fileno $files{ $1 } ) { open $files{ $1 }, '>', "$1.tmp" or die "Couldn't open $1.txt. +..\n"; } print { $files{ $1 } } "$2 $3\n"; }

Replies are listed 'Best First'.
Re^2: hash element as file handle
by halfcountplus (Hermit) on Mar 28, 2009 at 19:53 UTC
    print { $files{$1} } works, as does using a temp scalar (my $tmp = $files{$1}; print $tmp "...).

    Thanks!