... 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:  <%-{-{-{-<


In reply to Re: Error Unitialized value and use by AnomalousMonk
in thread Error Unitialized value and use by tryingnottofailmytes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.