[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [texlive-new] Creating rules file from a single template



On Fre, 22 Dez 2006, Mike Bird wrote:
> "sub myopen {" and "sub myopen($$) {" are both valid but
> "sub myopen() {" declares a sub with zero args.

Forget it, I meant
	sub myopen {
	...
	}
it is about that FOO is opened in the perl modules but the file handle
seems not to be available in the using perl code.

The problematic code is:
------ aaa.pm ----------
package aaa;
use Exporter ();
@ISA = qw( Exporter );
@EXPORT_OK = qw (myopen);
@EXPORT = @EXPORT_OK;

sub myopen {
        my ($a, $fn) = @_;
        open($a, $fn) or die "Cannot open $fn: $!\n";
        my $foo = <$a>;
        print "package aaa: This I read from $a: $foo...\n";
}

1;
---------------------


----- b.pl --------
use aaa;

myopen(FOO,"aaa.pm");

my @bar = <FOO>;
print "bar=@bar...\n";
-------------------


$ perl -w b.pl
Name "main::FOO" used only once: possible typo at b.pl line 6.
package aaa: This I read from FOO: package aaa;
...
readline() on unopened filehandle FOO at b.pl line 6.
bar=...
$

Any solution to this?

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining@logic.at>                    Università di Siena
Debian Developer <preining@debian.org>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
SCRAPTOFT (n.)
The absurd flap of hair a vain and balding man grows long above one
ear to comb it to the other ear.
			--- Douglas Adams, The Meaning of Liff



Reply to: