in reply to Re: undefined subroutine
in thread undefined subroutine

Thanks for replying with assistance. I've attempted both of these changes and am still receiving the same error. I must be doing something wrong, could you explain further if you don't mind?

Replies are listed 'Best First'.
Re^3: undefined subroutine
by hippo (Archbishop) on Apr 07, 2016 at 13:49 UTC

    Sure. I don't know what you've done to your script, but here's one which runs to completion and gives no such error message.

    #!/usr/bin/env perl use strict; use warnings; use YAML qw/LoadFile/; open my $fh, '<', '/dev/null'; my $config = LoadFile ($fh);

    Examine this code and compare it to your code. Start altering this code one line at a time to make it ever closer to your code, running it after each addition. If you hit a problem you will then know precisely which change caused the problem.

Re^3: undefined subroutine
by Anonymous Monk on Apr 07, 2016 at 13:52 UTC

    This code works fine for me.

    use strict; use warnings; use YAML qw(LoadFile); use Data::Dumper; # step 1: open file open my $fh, '<', 'config.yml' or die "can't open config file: $!"; # step 2: convert YAML file to perl hash ref my $config = LoadFile($fh); print Dumper($config), "\n";

    Although I have my doubts this is the reason, you could try upgrading your YAML.

    Note that YAML's own documentation recommends switching to YAML::XS.

      That's probably the best choice, thanks for you input.

Re^3: undefined subroutine
by Anonymous Monk on Apr 07, 2016 at 13:31 UTC

    Are you really getting this error?

    "Undefined subroutine &main::LoadFule called at test.pl line 18."

      Sorry, that's a typo.