in reply to data leak using package

I'd suggest using In direct Filehandles for situations like this. Also by shifting off the first parameter, the function is slightly more useful, you can call the function with any filename you wish, workspace( '/root_to_file' );

package wslib; use strict; our @EXPORT = qw( workspace ); #place all the variables you want to ex +port by default in here (c.f. @EXPORT_OK) use Exporter; our @ISA = qw(Exporter); sub workspace { my $data_reg = shift || return; open my $page, "$data_reg" or die "Cant open $data_reg: $!"; while (my $line = <$page>) { print "$line<br>"; } close $page; } 1;

Replies are listed 'Best First'.
Re^2: data leak using package
by Anonymous Monk on Feb 07, 2007 at 11:03 UTC
    Thanks for that info - I hadn't come across it before and it looks very useful. I'm definitely a convert!!