I am new to perl and am trying to get what I thought was a simple eq statement to work but something seems to be wrong with my syntax. This is the code I am running
for ($y = 0; $y < $length ; $y++ ) { my($arg); $arg = $_[$y]; if ( length $arg == 1 ) { $and = $and . " AND j$y.LumbolValue = '$arg' " ; } elsif ( $arg eq "vowel\n"){ $and = $and . " AND j$y.Vowel = 1 " ; } elsif ( $arg eq "consonant\n"){ $and = $and . " AND j$y.Consonant = 1 " ; } elsif ( $arg eq "alpha\n"){ $and = $and . " AND j$y.Letter = 1 " ; } else { $and = $and . " /* else: y: $y arg: [$arg] */ " ; } }
On every iteration only the "else" block runs and my output is basically:
/* else: y: 0 arg: [vowel] */ /* else: y: 1 arg: [c] */ /* else: y: 2 +arg: [e] */ /* else: y: 3 arg: [consonant] */
I originally tried writing the eq statements without \n but added those chracters after is supposedly was helpful to someone else. Thanks in advance for any help, I have been stuck on this for over an hour so any help would be extremely welcome.

In reply to eq statement not working by Anonymous Monk

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.