in reply to Opening files in 5.004 and 5.8

To minimise the amount of code you have to change, I would just conditionally bring in the Symbol module, and call gensym to initialise your file handle, and ditch the 'RPT' stuff.

use Symbol; sub printSumpn{ my($handle, $file) = (gensym(), '/tmp/report.txt');

And everything will work just fine. You don't actually care about what the handle itself looks like, just that it uniquely identifies whatever it's printing to. gensym does that for you.

• another intruder with the mooring in the heart of the Perl

Replies are listed 'Best First'.
Re^2: Opening files in 5.004 and 5.8
by educated_foo (Vicar) on May 12, 2007 at 17:35 UTC
    Ugh, another module for the "CPAN one-liners" file:
    sub gensym { \*{'__GEN__' . ++$__GEN__::__counter__} }
    It's a useful function, but not worth an extra dependency.
      FWIW, Symbol has been core since 5.002.

      Also see the comment on copying the glob vs. making a reference in the Symbol.pm implementation.