Perl 4 programmers especially may be surprised to find that as of Perl 5.0 the ampersand & may be omitted in a call to a subroutine if the subroutine has been declared before being used. Actually you can even get around the declare before omit ampersand rule by using the subs.pm pragma, or by pre-declaring (without defining) as in a script like:
#!/usr/bin/perl -w
use strict;
use Tk;
sub Mysub; #pre-declare allows calling Mysub()
...Other main/Tk stuff -
including call to Mysub() sans &...
sub Mysub {
...Mysub stuff...
}
Note however that one place the \& reference is
sometimes used in perl/Tk in the setting up a callback for a widget.
Other references are possible: e.g. \$foo is a
reference to the scalar variable $foo (this was true even
under perl 4).
Previous | Return to table of contents | Next