It works fine from my tests without the BEGIN block since $sub is initialized before the compiler will get to GlobalRoutine.
Then I guess you missed my addition last time. Here:
- tye (but my friends call me "Tye")#!/usr/bin/perl -w use strict; exit main( @ARGV ); { my $sub; ## BEGIN { $sub= sub { warn "Called local sub: @_\n"; }; ## } sub GlobalRoutine { &$sub( "Test" ); } } sub main { GlobalRoutine("hi"); return 0; } __END__ This produces the following: Use of uninitialized value in subroutine entry at localsub.pl line 14. Can't use string ("") as a subroutine ref while "strict refs" in use a +t localsub.pl line 14.
In reply to (tye)Re3: Functions
by tye
in thread Functions
by fgcr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |