May 5, 2004 #1 arcnon Programmer Aug 12, 2003 242 US Can't use string ("Menu::quit_now") as a subroutine ref while "strict refs" in use when I comment out use strict it works fine how do I get it to work WITH use strict thanks
Can't use string ("Menu::quit_now") as a subroutine ref while "strict refs" in use when I comment out use strict it works fine how do I get it to work WITH use strict thanks
May 5, 2004 #2 rharsh Technical User Apr 2, 2004 960 US Can you post the pertinent code? Upvote 0 Downvote
May 6, 2004 #3 thenewa2x Programmer Dec 10, 2002 349 US you can also do this: [tt] #!/usr/bin/perl use strict; no strict 'refs'; [/tt] --------------------------------------- If you helped... thx. Upvote 0 Downvote
you can also do this: [tt] #!/usr/bin/perl use strict; no strict 'refs'; [/tt] --------------------------------------- If you helped... thx.
May 7, 2004 Thread starter #4 arcnon Programmer Aug 12, 2003 242 US I figured it out the solution is: # hash built dynamiclly from a file %menu_list = ( '3' => 'Menu::new_character', '4' => 'Menu::quit_now' ); $input = <STDIN>; chomp $input; if ($menu_list{$input}){ $bar = \&{$menu_list{$input}}; } Upvote 0 Downvote
I figured it out the solution is: # hash built dynamiclly from a file %menu_list = ( '3' => 'Menu::new_character', '4' => 'Menu::quit_now' ); $input = <STDIN>; chomp $input; if ($menu_list{$input}){ $bar = \&{$menu_list{$input}}; }
May 7, 2004 #5 thenewa2x Programmer Dec 10, 2002 349 US you might want to do this: eval($menu_list{$input}) if( exists $menu_list{$input}); --------------------------------------- If you helped... thx. Upvote 0 Downvote
you might want to do this: eval($menu_list{$input}) if( exists $menu_list{$input}); --------------------------------------- If you helped... thx.