The order in which you run things is different. Normally, the module is executed when it is loaded (by use). Now it's executed after your print statements. I wrap my inlined packages with BEGIN, which makes it more like use.
#!/usr/bin/perl -w use strict; BEGIN { package MyModule; ... } my $thingy = new MyModule ( 'thing2' ); print "yeah!\n" if $thingy->is_thing(); print "boo!\n" unless $thingy->is_thing();
In reply to Re: Defining a package inside my script?
by ikegami
in thread Defining a package inside my script?
by Plankton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |