Dear wise Monks,
I have been using a package I wrote like so ...
I would run my script and get output of "yeah!". The code for MyModule is a file MyModule.pm. It declares an array that is global inside the module. Something like this ...$ cat myscript.pl #!/usr/bin/perl -w use strict; ... use lib('.'); use MyModule; ... my $thingy = new MyModule ( 'thing2' ); print "yeah!\n" if $thingy->is_thing(); print "boo!\n" unless $thingy->is_thing();
I decided to move the module in side my script like so I commented out the lines like so ...$ cat MyModule.pm package MyModule; use strict; my @things = ( 'thing1' , 'thing2' , 'thing3' , ); sub is_thing { my $self = shift; my $t = $self->{'thing'}; return grep /^$t$/, $things; } ... 1;
... then I made a new script like so ...#use lib('.'); #use MyModule;
Now my script behaves as if @things is empty. What did I do wrong?$ cat myscript.pl MyModule.pm > newscript.pl $ ./newscript.pl $ boo!
In reply to Defining a package inside my script? by Plankton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |