Mailing List Archive

Death From Filehandles, 3rd try- Help, pretty please? Somone???
I'll try again, I posted this sample yesterday and haven't heard a thing. All
the bits work on their own, but not in this scenario...
(Send replies to amon@gpl.com, not to Reply-To address.)

=========================
I may well have bad syntax here - I've never fully grokked how filehandles are
supposed to work - but the results are rather unexpected...

===== test2
use lib "/Users/amon/cgi-bin";
require testC;
require testA;
my ($x, $y, $z);
$z = new testA;
$x = new testC;
$y = nextID $x;

===== testA
require testB;
package testA;
sub new
{ my $type = shift;
$db = {};

&::LoadDataFromFile;
bless $db, $type;
return $db;
}

1;

===== testB
sub OpenOrDie
{ local(*FILE);
open (FILE, "</Users/amon/tst1");
return (*FILE);
}
sub LoadDataFromFile
{ local(*DATAFILE);
*DATAFILE = OpenOrDie;
close (DATAFILE);
}

====== testC
package testC;
sub new
{ my $type = shift;
$self = {};
bless $self,$type;
return $self;
}

sub nextID {return 1;}

1;

======= command line
>test2

Loading DB routines from $RCSfile: perl5db.pl,v $$Revision: 4.1 $$Date:
92/08/07
18:24:07 $
Emacs support available.

Enter h for help.

main::(test2:3): require testC;
DB<1> c
Can't call method "nextID" without a package or object reference at test2 line
8.
>

>cat /Users/amon/tst1
testing
>

Suggestions?