Dan Anderson wrote:
> What is really driving me bonkers is if I try the following code:
>
> use strict;
> use warnings;
>
> END
> {
> print "Look ma, i'm using subroutines!";
> foo::foo();
> }
>
> BEGIN
> {
> print "\nouter\n";
> BEGIN
> { print "\ninner\n"; }
> }
> print "end\n";
>
>
> BEGIN
> {
> package foo;
> foo();
> BEGIN
> {
> sub foo()
> { print "\nfoo\n"; }
> }
> }
>
> I get:
>
>
> inner
>
> outer
> foo::foo() called too early to check prototype at ./ad_module.pl line
> 21.
>
> foo
> end
> Look ma, i'm using subroutines!
> foo
>
> I don't understand why if BEGIN blocks can have different priorities a
> warning would be put out.
the warning you see actually has very little to do with being inside the
BEGIN{} block. even without the begin block:
#!/usr/bin/perl -w
use strict;
fun;
sub fun(){
print "hi\n";
}
__END__
still generate the same wanring:
main::fun() called too early to check prototype at ./tmp.pl line 14.
hi
if you don't want to see the warning, you can disable prototype:
#!/usr/bin/perl -w
use strict;
BEGIN{
&fun;
BEGIN{
sub fun(){
print "hi\n";
}
}
}
__END__
prints:
hi
generally speaking, '&fun' is NOT the same as 'fun()' but in this case, it
doesn't make any difference.
BEGIN{} block are executed in FIFO (first in first out) order and END{}
block are executed in LIFO (last in first out) order.
david
--
$_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$";
map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#,
goto=>print+eval
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]