Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: sanity check

by cdarke (Prior)
on Sep 21, 2011 at 05:56 UTC ( #927081=note: print w/ replies, xml ) Need Help??


in reply to sanity check

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/.


Comment on Re: sanity check
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927081]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2014-09-23 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (212 votes), past polls