Hi all, I'm relatively new to Perl and particularly new to regular expressions.
This is really simple script I've just mocked up. All it does is to take the input string and check if it's in the correct format or not.
Here are some examples of correct format (will always be three letters followed by a '-' followed by three numbers):
TJD-111
IIS-193
XTT-920
If a user enters input without the '-' E.g:
JDJ222
XTT920
Then add a '-' between the characters/numbers.
Simple eh?
use strict;
print "Enter Defect Number: ";
my $text = <STDIN>;
if ($text =~m/-/)
{
print "the input is correct\n";
# do some other stuff
}
else
{
print "The string needs a minus \n";
# In this case, append the '-'
}