... it didn't work.
Exactly what is "it"? Exactly how did it "not work"?
... my variables are unintilized when I initilize them at the beginning.
You assign values at the beginning, but then you assign again from the result of a match, and that's probably where the undefined values come from: regex captures return undef when the match fails. (Update: More precisely, a failed match in list context, as below and in the OPed code, returns an empty list, which, when assigned to scalar variables, yields undefs.) You have to test the success of the match somehow:
c:\@Work\Perl\monks>perl -wMstrict -le
"my $s = 'eks---wye';
;;
my $found = my ($x, $y) = $s =~ m{ \A (eks) .* (wye) \z }xms;
if ($found) {
print qq{A: found '$x' and '$y'};
}
else {
print 'A: found nada';
}
;;
$s = uc $s;
;;
if (my ($xx, $yy) = $s =~ m{ (EKS) .* (WYE) }xms) {
print qq{B: found '$xx' and '$yy'};
}
else {
print 'B: found nada';
}
"
A: found 'eks' and 'wye'
B: found 'EKS' and 'WYE'
Play with that, change the string value and the match regexes, until you're confident of what's going on. (Of course, there are other ways to test match success.) The usual links:
perlre,
perlretut, and
perlrequick.
Give a man a fish: <%-{-{-{-<