You could return the data by reference... The documentation is at
perldoc perlref
But in summary it would be
sub parse
{
my $hashRef = {};
$hashRef->{ONE} = 45;
return $hashRef
}
my $result = parse();
print $result->{ONE};
-----Original Message-----
From: Martijn van Exel [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 17, 2001 2:38 PM
To: [EMAIL PROTECTED]
Subject: referencing and subroutines.
Hi all,
I'm new to this list and quite new to Perl. I'm on digest, so I'd
appreciate a cc.
I have written a subroutine to parse a text file containing a flat file
database. The data ends up in a hash of hashes, say %datafile. This hash is
created on the spot, looping through the data in a foreach loop. The data
coud then be retrieved using $datafile{$record}{$fieldname}. This seems to
work, but the hash won't travel with me out of the subroutine. I'm not
using strict, so I'm being messy with my declarations, probably. Do I need
to end the subroutine using return?
Any help greatly appreciated.
--
martijn van exel -- [EMAIL PROTECTED] -- http://huizen.dds.nl/~mvexel