godfetish has asked for the wisdom of the Perl Monks concerning the following question:
Yet, assigning the handle to a temporary variable and placing that temp var into the printf works...#!/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);
Why? I have tried backslashing the hashed handle, backslash star, dereferencing the hashed value as scalar and hash...Mostly seeing STDOUT is scalar and FileHandle is GLOB, but this doesn't really explain the why for printf acting this way to a hash reference versus the scalared value...... my $uuh = $uHHash{uHANDLE}; printf($uuh "Output is here (%s) !\n","HJGKJGJHJLHL"); close($uHHash{uHANDLE}); exit(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Odd Hashed Filehandle behavior
by Fletch (Bishop) on Feb 26, 2010 at 15:24 UTC | |
|
Re: Odd Hashed Filehandle behavior
by keszler (Priest) on Feb 26, 2010 at 15:30 UTC | |
by godfetish (Novice) on Feb 26, 2010 at 16:11 UTC |