in reply to Odd Hashed Filehandle behavior

printf {$uHHash{uHANDLE}} "Output is here (%s) !\n","HJGKJGJHJLHL";
From the print documentation:
Note that if you're storing FILEHANDLEs in an array, or if you're using any other expression more complex than a scalar variable to retrieve it, you will have to use a block returning the filehandle value instead:
print { $files[$i] } "stuff\n"; print { $OK ? STDOUT : STDERR } "stuff\n";

Also, if reading from a filehandle stored in a hash you cannot use @x = <$hash{key}>;, you need to use @x = readline($hash{key});

Replies are listed 'Best First'.
Re^2: Odd Hashed Filehandle behavior
by godfetish (Novice) on Feb 26, 2010 at 16:11 UTC
    That's it!
    #!/usr/bin/env perl #$Name$ #$Id$ use FileHandle; my $FName = shift(@ARGV) || ""; my %uHHash; if ($FName ne "") { open($uH, ">".$FName); $uHHash{uHANDLE} = $uH; } else { $uHHash{uHANDLE} = STDOUT; } printf({$uHHash{uHANDLE}} "Output is here (%s) !\n","HJGKJGJHJLHL"); close($uHHash{uHANDLE}); exit(0);
    After the first reply, I tried something similar, but I see my mistake now. Thanks... jrk