I am trying to use symbols from Utils.pm without qualifying them with
package name. I have 2 files:

#############################
# File Utils.pm
#############################
package Utils;

use warnings;
use strict;

use base 'Exporter';
our @EXPORT_OK = ('foo', 'bar');

sub foo {
    print "foo!\n";
}
sub bar {
    print "bar!\n";
}

#############################
# The program (1)
#############################
use warnings;
use strict;
use Utils qw(bar foo);

foo();
bar();

If both files are in the same directory, this works fine:

$perl ./prog1.pl
foo!
bar!

When I, however, move Utils.pm into subdirectory mylib, and modify the
program accordingly:

#############################
# The program (2)
#############################
use warnings;
use strict;
use mylib::Utils qw(bar foo);

Utils::foo();
bar();

then only the first call works:

$perl prog1.pl
foo!
Undefined subroutine &main::bar called at prog1.pl line 6.

What is the problem?

Thanks!

STF

=======================================================================
http://eisenbits.homelinux.net/~stf/
OpenPGP: DFD9 0146 3794 9CF6 17EA  D63F DBF5 8AA8 3B31 FE8A
=======================================================================

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to