Cambridge10
Programmer
Hi,
I'm new to Perl using regex.
I wrote a simple program which search the userinput for a match.
When I start the program it works fine but I get the error message below.
I'm doing something wrong but what exactly?
The error message :
Use of unintialized value $_ in pattern match (m//) at test.pl line 8, <STDIN> line 1.
The code :
I'm new to Perl using regex.
I wrote a simple program which search the userinput for a match.
When I start the program it works fine but I get the error message below.
I'm doing something wrong but what exactly?
The error message :
Use of unintialized value $_ in pattern match (m//) at test.pl line 8, <STDIN> line 1.
The code :
Code:
#!/usr/bin/perl -w
print "enter any word: ";
$userinput=<STDIN>;
chomp $userinput;
if ($userinput = /[A-Z]/)
{
print " matched the pattern $userinput\n";
}
else
{
print "No match";
}