Comment out the line with 'eval', and print it instead
#eval $code;
print $code;
You might be surprised at the value of $code.
I'm sure you already know this, but I'll repeat it anyway - double quotes interpolate contained variables, single quotes do not. perl is trying to eval if ($port_a $cmp_op $port_b)... which is destined to fail - it won't even compile. In order to evaluate it properly, $code needs to to contain if ($port_a < $port_b)....
I'll leave it for you to construct the string properly ;) Once you do, comment the print and uncomment the eval.
BTW, what are you trying to accomplish? Could there be a better way?
Update: BTW, I didn't see your update until after posting this node. I assume most would see it easier if you posted a response instead the update.
Update #2 Update #1 is directed at the OP, not xenchu
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.