> On Aug 12, Randy Macdonald said:
>
> > However, when I run:
> >
> > print '<a>';
> > use NotARealPackage;
> > print '<b>';
> >
> > I expect to get:
> >
> > <a>
> >
> > but I get no output at all. Why is this?
>
> The 'use' statement is special to Perl.  It is executed at compile-time,
> not at run-time like most of the rest of your code.  Because of this, your
> print() statements are never even executed.  In fact, only the first one
> ends up being compiled -- Perl never REACHES the second one at all, since
> it has tried to include the NotARealPackage module.
>

One way you can possibly force this is to use a BEGIN{} block which is
compiled/executed before the main script is compiled. A begin block may
occur anywhere in the script. However, Im not sure if this holds any real
utility.

BEGIN{print '<a>'};
use NotARealPackage;
print '<b>';

Manav



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to