Basically you need to import the parse_yaml
subroutine into you current program, rather than trying to export the value of the parameter, but I'm uncertain why you have written your own parse_yaml
utility when YAML::XS::LoadFile
has already done it for you
This is all very clearly described in the documentation for the Exporter
module
Here's a brief example
main.pl
use strict;
use warnings 'all';
use YAML::XS 'LoadFile';
use MyUtils 'parse_yaml';
my $input_file = 'data.yaml';
my $yaml_input = LoadFile($input_file);
parse_yaml($input_file);
# this variable has to be passed to the function parse_yaml which is in other file.
MyUtils.pm
package MyUtils;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT_OK = 'parse_yaml';
sub parse_yaml {
my ($yaml_file) = @_;
# some processing
}
1;