#!/usr/bin/env perl -l use strict; use warnings; use File::Spec; my ($dir, $file) = qw{pm_1190415/external external_hash}; my $extern_hash = get_extern_hash($dir, $file); print "@{$extern_hash->{scopeX}{modelB}}"; print "@{$extern_hash->{scopeZ}{modelA}}"; sub get_extern_hash { my $path = File::Spec::->catfile(@_); our %hash; require $path; return \%hash; }