Ther are all kinds of issues with your code, and others have pointed some of them out, I'll try to explain. A major problem you have is with the for statement, which you seem to be using instead of if. In Perl, for is a type of loop for walking through items in a list. Secondly you are using a single = sign. In many languages, including Perl, a single = is an assignment. In Perl, to do a numeric comparison you use ==, and to do a textual comparison use eq. If we assume that object-group is supposed to be text, then that should be enclosed with quotes. So we are left with: if ($array[0] eq 'object-group') {
print OUTPUT "set shared address-group $array[2]\n";
}
As for the rest, people used to code Perl in that way back in the 20th century, but things have moved on since then. Try running your code through Perl::Critic or http://perlcritic.com/.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|