I have since changed my module because of your suggestions in your previous post. I don't think the error is due to the @$game symbolic reference. I use only the array named @maps in my sub now.
Here it is:
use strict;
use warnings;
use diagnostics;
package HLDS;
use Exporter ();
our $VERSION = 1.00;
our @ISA = qw(Exporter);
our @EXPORT = ();
our @EXPORT_OK = qw(array);
# Create Map Array given an argument.
sub GameMaps
{
# Declare Variables
my ($game) = @_;
my $user = $ENV{'USER'};
# Create Dir Path
my $dir = "/home/$user/hlds_l/$game/maps/";
# End if dir not exist
return unless -d $dir;
#Read maps from directory
my @maps;
opendir(my $maps_dh, $dir) || die("Cannot open directory");
@maps = readdir($maps_dh);
closedir($maps_dh);
# Take only maps and trim .bsp
@maps=grep /\.bsp/, @$game;
foreach my $map (@maps)
{
$map=~ s/\.bsp//
}
return @maps;
}
1;
# end