Perl is not PHP, Perl has different comparison operators for strings and for numbers. That is because Perl doesn't really let you distinguish between whether a value is a string or a number. So, is "0" == "00"? Perl resolves that ambiguity by explicitely making you treat the scalars as strings, or as numbers. == is for numbers, eq is for strings. See perlop.

Oh, and you have one more major problem: you're declaring your $link variables every time inside the code blocks. That limits their scope to that block, so there's no way you can access these variables outside those blocks. What you have, is a bunch of independent variables all called $link.

What you need is one declaration, at the top. You have that. Just drop the my on every other line that refers to $link. Like this:

my $link = "err"; if ($q->param('title') eq "Political Animal") { $link = "pa"; } ...

In reply to Re: Help with an IF? by bart
in thread Help with an IF? by barrycarlyon

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.