in reply to Re: (tye)Re2: Functions
in thread Functions
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re3: Functions
by KM (Priest) on Jan 30, 2001 at 02:24 UTC | |
by tye (Sage) on Jan 30, 2001 at 02:42 UTC | |
by KM (Priest) on Jan 30, 2001 at 02:55 UTC |