in reply to switch and case statement using a function

First, please always "use strict" and "use warnings". This will catch a lot of code problems, as you'll see with the example below and your "$i" declaration. Secondly, you try to call your test_func as a sub...without declaring it as a sub. Your code should look like this(you need to fix $i):
#!/usr/bin/perl use strict; # always do this! use warnings; # always do this! use Switch; my $i; # we declare it, but never assign it. chomp(my $var = <STDIN>); switch ($var) { case(1) { test_func() } } print "case: $i\n"; # perl complains..$i is not assigned sub test_func { print "\nhello"; }