in reply to How to call subroutines using variables ?
It's probably better to use a reference to the subroutine instead of its name:
#!/usr/local/bin/perl use strict; use warnings; my $s = \&res; $s->(); sub res { print "hai"; }
edit: see also perlref
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to call subroutines using variables ?
by Trizor (Pilgrim) on Mar 22, 2007 at 23:02 UTC | |
|
Re^2: How to call subroutines using variables ?
by bradcathey (Prior) on Jun 09, 2007 at 17:31 UTC | |
by blazar (Canon) on Jun 09, 2007 at 17:56 UTC | |
by bradcathey (Prior) on Jun 09, 2007 at 19:48 UTC | |
by chromatic (Archbishop) on Jun 10, 2007 at 04:23 UTC | |
by bradcathey (Prior) on Jun 10, 2007 at 12:25 UTC | |
| |
by blazar (Canon) on Jun 10, 2007 at 07:32 UTC |