in reply to sharing filehandles

Try this for SetLog:
sub SetLog { my $glob = shift; *LogFile = *$glob; }
Update: *LogFile = *{shift()} also works.

In general, though, I would avoid using barewords as file handles in this case and use scalars instead. "Advanced Perl" came out over 10 years ago, and a lot of practices have changed since then. (Update: I suppose you could have the 2005 edition, but still...) To pass file handles around it's just better to use scalar refs:

package test_a; my $LOGFH; sub SetLog { $LOGFH = shift; } sub TestLog { print $LOGFH "test_a::TestLog...\n"; } package main; ... test_a::SetLog(\*LOGF);

Replies are listed 'Best First'.
Re^2: sharing filehandles
by Wiggins (Hermit) on Jun 29, 2008 at 23:52 UTC
    Ref: "I suppose you could have the 2005 edition, but still..."

    I do have the "2nd edition", which, during a quick scan, I find to be a complete mis-naming. It should be "Volume 2". Since the author is different; and there appears to be little overlap in the subject matter.So, it is volume 2, focusing on topic in vogue 10 years later.

    I will be looking into the suggested solutions. I failed to mention that the eventual run-time environment is MS XP, using ActiveState. That means I prefer any solution that does not depend upon packages that may not be available in both environments.
    And thanks to all the quick responses!!