I am trying to write a perl script having a menu in which user selects one in list (1-3) and then asks the user to enter a string (depending on menu selected) which should be read as input and printed in console. However when executing script, I am finding this error. What could be wrong here?
~] # perl sample.pl
Global symbol "$user" requires explicit package name at ./sample.pl line 26.
Global symbol "$user" requires explicit package name at ./sample.pl line 27.
Global symbol "$user" requires explicit package name at ./sample.pl line 28.
Global symbol "$process" requires explicit package name at ./sample.pl line 37.
Global symbol "$process" requires explicit package name at ./sample.pl line 38.
Global symbol "$process" requires explicit package name at ./sample.pl line 39.
Missing right curly or square bracket at ./sample.pl line 52, at end of line
syntax error at ./sample.pl line 52, at EOF
Execution of ./sample.pl aborted due to compilation errors.
#!/usr/bin/perl
use strict;
use warnings;
use Switch;
my $input = '';
while ($input ne '3')
{
clear_screen();
print "1. user\n".
"2. process\n".
"3. exit\n";
print "Enter choice: ";
$input = <STDIN>;
chomp($input);
{
case '1'
{
print "Enter user";
$user = <STDIN>;
chomp ($user);
print "User is $user\n";
}
case '2'
{
print "Enter process:";
$process = <STDIN>;
chomp ($process);
print "Process is $process\n";
}
}