Hi Monks, I am trying to use a function in the switch statment. I am getting the error. $ perl switch_test.pl 1 Undefined subroutine &main::test_func called at switch_test.pl line 8, <STDIN> line 1. Please tell what I need to do? Do I need to use main() sommewhere?
use Switch; $i; chomp($var=<STDIN>); switch ($var){ case(1) { test_func()} } print "case: $i\n"; test_func{ print "\nhello"; }
In reply to switch and case statement using a function by ashish_sun123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |