M
matg
I'm sure this is a basic Perl question but I'm a newbie and can't seem
to get my head around it.
I want to pass 3 parameters eg. ("WM","windows","30/12/2005 00:00:00")
to a subroutine that will open a file and return an associative array
to the calling procedure - I believe the issue may lie in the way I
call the sub - any clues? The sub executes correctly and does create
the array but I can't seem to read anything from it once it is returned
(i.e. the foreach loop produces nothing)
Abridged code follows
@Group = "WM";
@Env = "windows";
@Timekey = "30/12/2005 00:00:00";
$Books = &returnBooks(@Group, @Env, @Timekey);
foreach $Book(keys %Books){
print "loop: ".$Book."\n";
}
sub returnBooks{
# Extract parameters
my ($x, $y, $z) = @_;
.......
Open file and create array
if ($BusinessGroup eq $GROUP) {
$BusinessGroups{$Book}=$BusinessGroup;
}
.......
return \%BusinessGroups;
to get my head around it.
I want to pass 3 parameters eg. ("WM","windows","30/12/2005 00:00:00")
to a subroutine that will open a file and return an associative array
to the calling procedure - I believe the issue may lie in the way I
call the sub - any clues? The sub executes correctly and does create
the array but I can't seem to read anything from it once it is returned
(i.e. the foreach loop produces nothing)
Abridged code follows
@Group = "WM";
@Env = "windows";
@Timekey = "30/12/2005 00:00:00";
$Books = &returnBooks(@Group, @Env, @Timekey);
foreach $Book(keys %Books){
print "loop: ".$Book."\n";
}
sub returnBooks{
# Extract parameters
my ($x, $y, $z) = @_;
.......
Open file and create array
if ($BusinessGroup eq $GROUP) {
$BusinessGroups{$Book}=$BusinessGroup;
}
.......
return \%BusinessGroups;