Program Code:
#!/Perl/bin/perl
print("Enter the variable name \n");
$input=<STDIN>;
chop($input);
if($input =~ /^\$[A-Za-z][_0-9a-zA-Z]*/)
{
print("$input is a valid scalar variable name in perl \n");
}
elsif($input =~ /^\@[A-Za-z][_0-9a-zA-Z]*/)
{
print("$input is a valid array variable name in perl \n");
}
else
{
print("$input is not valid \n");
}
Output:
#!/Perl/bin/perl
print("Enter the variable name \n");
$input=<STDIN>;
chop($input);
if($input =~ /^\$[A-Za-z][_0-9a-zA-Z]*/)
{
print("$input is a valid scalar variable name in perl \n");
}
elsif($input =~ /^\@[A-Za-z][_0-9a-zA-Z]*/)
{
print("$input is a valid array variable name in perl \n");
}
else
{
print("$input is not valid \n");
}
Output:
0 comments:
Post a Comment