BlueLines has asked for the wisdom of the Perl Monks concerning the following question:
This fails miserably with:#!/usr/bin/perl -w use strict; my %Foo = ('Routine' => 1, 'Option' => 0); foreach (keys %Foo) { &$_() if $Foo{$_}; } sub Routine { print "We're in routine.\n"; } sub Option { print "We're in option.\n"; }
This snippet works if I add this line: no strict 'refs';Can't use string ("Option") as a subroutine ref while "strict refs" in + use at ./foo.pl line 7.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:
by rlk (Pilgrim) on Oct 06, 2000 at 07:47 UTC | |
|
Re: "No strict refs" will be the death of me
by btrott (Parson) on Oct 06, 2000 at 07:51 UTC | |
|
(dchetlin: Evil trick) Re: No strict refs etc...
by dchetlin (Friar) on Oct 06, 2000 at 12:58 UTC | |
|
use the symbol table (re: strict refs)
by japhy (Canon) on Oct 06, 2000 at 16:04 UTC |