From: Gan Uesli Starling <[EMAIL PROTECTED]>
> I get this complaint from 'use strict';
> 
>  > Bareword "ckKeyBts" not allowed while "strict subs"
>  > in use at gus_perl/FYBB_DirTree.pm line 425.
> 
> I know what it means. I have a sub which is defined
> later in the script than it is called on line 425.
> 
> After I put an ampersand onto &ckKeyBts at line 425
> strict stopped whining.
> 
> My question is: what happens when this is the case?
> Does Perl, on encountering this former bareword with
> ampersand now attached, execute the sub which
> is later defined, or does something less desireable
> happen?

After you put the & there it does the right thing. Almost.
That is it calls the procedure. But it gives the procedure the 
current @_. Almost as if you wrote
        ckKeyBts(@_);

        #!perl
        sub outer {
                print "Called outer( '", join( "', '", @_), ")\n";
                &ckKeyBts;
                print "Exit outer( '", join( "', '", @_), ")\n";
        }
        
        sub ckKeyBts {
                print "Called ckKeyBts( '", join( "', '", @_), ")\n";
                print "Exit ckKeyBts( '", join( "', '", @_), ")\n";
        }
        
        outer(1,2,10,20);
        __END__

It get's even worse:

        #!perl
        sub outer {
                print "Called outer( '", join( "', '", @_), ")\n";
                &ckKeyBts;
                print "Exit outer( '", join( "', '", @_), ")\n";
        }
        
        sub ckKeyBts {
                print "Called ckKeyBts( '", join( "', '", @_), ")\n";
                $_[0] = 'gotcha';
                print "Exit ckKeyBts( '", join( "', '", @_), ")\n";
        }

        $x = 1;
        outer( $x,2,10,20);
        print "\$x=$x\n";
        __END__

or even

        #!perl
        sub outer {
                print "Called outer( '", join( "', '", @_), ")\n";
                &ckKeyBts;
                print "Exit outer( '", join( "', '", @_), ")\n";
        }
        
        sub ckKeyBts {
                print "Called ckKeyBts( '", join( "', '", @_), ")\n";
                my $first = shift();
                print "Exit ckKeyBts( '", join( "', '", @_), ")\n";
        }

        outer( 1,2,10,20);
        __END__

So it's probably not the best thing to do.

I'd recommend either
        ckKeyBts();
or to define or declare the function before you use it.

By "declare function" I mean

        sub ckKeyBts;
or (if it is not going to get any parameters)
        sub ckKeyBts ();

HTH, Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to