Your my $shell
is lexical inside of the if
block. Move it outside the if
or it is not available there. Adding some indentation helps to spot that.
my $shell;
if ($shelltype == 1) {
$shell = \%multicity;
} else {
$shell = \%singlecity;
};
After that, you will get a warning saying %shell
is undefined. That's because you are using $shell{url}
but you defined $shell
as a hash ref, so you need $shell->{url}
or $$shell{url}
in your print
.