C
Coolio
hi,
in a file 'nap.pl', i have some code like this:
#!/usr/bin/perl -w
use strict;
Foo->import(nap);
nap();
{
package Foo;
use Exporter;
@Foo::ISA = qw(Exporter);
@Foo::EXPORT = qw(nap);
sub import {
Foo->export_to_level(1, @_);
}
sub nap {
select undef, undef, undef, 0.25;
print "Hi\n";
}
}
now if i run 'nap.pl', i'll get error "Can't locate object method
"export_to_level" via package "Foo"". how can i import subroutine
'nap' into 'main' from Foo? for simplicity, i removed package
variables from the example; thus, i'd like to keep the outer curly
brackets to maintain scope for these package variables. thanks.
in a file 'nap.pl', i have some code like this:
#!/usr/bin/perl -w
use strict;
Foo->import(nap);
nap();
{
package Foo;
use Exporter;
@Foo::ISA = qw(Exporter);
@Foo::EXPORT = qw(nap);
sub import {
Foo->export_to_level(1, @_);
}
sub nap {
select undef, undef, undef, 0.25;
print "Hi\n";
}
}
now if i run 'nap.pl', i'll get error "Can't locate object method
"export_to_level" via package "Foo"". how can i import subroutine
'nap' into 'main' from Foo? for simplicity, i removed package
variables from the example; thus, i'd like to keep the outer curly
brackets to maintain scope for these package variables. thanks.