chiller has asked for the wisdom of the Perl Monks concerning the following question:
Say I have this:
This gives me Can't use string ("\&logoff(@)") as a subroutine ref while "strict refs" in use at (eval 69) line 113. Alternately:%states = ( 'Default' => '\&front_page(@)', 'Lost' => '\&lost(@)', );
This gives me a syntax error (on the last line with the end-paren and semicolon).%states = ( 'Default' => \&front_page(@), 'Lost' => \&lost(@), );
What gives? What is the right way to do this? I was trying to just copy the text out of the Perl Cookbook but that didn't seem to work (with the syntax error and all). The syntax error IS in this somewhere--I commented it out, and perl -c said everything else was OK. Maybe I should just turn off 'strict refs' but I'd like to know which way I'm *supposed* to be doing things.
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Subroutine Reference with use strict
by rinceWind (Monsignor) on Apr 13, 2002 at 09:47 UTC | |
by chiller (Scribe) on Apr 13, 2002 at 20:44 UTC | |
|
Re: Subroutine Reference with use strict
by mirod (Canon) on Apr 13, 2002 at 11:52 UTC | |
|
Re: Subroutine Reference with use strict
by Juerd (Abbot) on Apr 13, 2002 at 17:39 UTC | |
by chiller (Scribe) on Apr 13, 2002 at 20:41 UTC | |
by Anonymous Monk on Apr 14, 2002 at 01:32 UTC | |
|
Re: Subroutine Reference with use strict
by chiller (Scribe) on Apr 14, 2002 at 01:59 UTC |