With great effort I'm pulling myself out from behind a pile of O'Riellys and climbing the mountain the seek guidance.
Using ActivePerl (5.8) I get the following errors:
syntax error at D:\plscipts\fwimport.pl line 44, near "sub nameimport +" Global symbol "@name" requires explicit package name at D:\plscipts\fw +import.pl line 47. Execution of D:\plscipts\fwimport.pl aborted due to compilation errors +.
For the following script:
#!/bin/perl -W # This script is for the importing of Pix firewall configs. # This script requires Acitve Perl with the DBI module # and DBD module for ODBC. Also a user DSN needs to be made for # the FWexcept database to be used named FW. # # This script is for internal use, it has not been built to # production standards. There are no input or performance # sanity checks. # # For the sake of my sanity I'm continuing to use my naming standard # for DBI functions. For database handles the convention is "(name)db" # where (name) is the database name. For all SQL commands the # convention is "name""table""SQL command type", where the table is # the table/s names and "SQL command type" is qry, ins, upd, or del. use strict; use DBI; # get the firewall config, submited as an argument # the config will be passed to the script as the array @config if (/$ARGV[0]/) { open (CONFIG,"$ARGV[0]") || die "Could not open $ARGV[0]\n"; my @config = <CONFIG>; close (CONFIG); } # connect to the DSN on the local system database handles end in db my $FWdb = DBI->connect('DBI:ODBC:FW'); # Build insert statement for the exception table my $FWexceptioninst = $FWdb->prepare(q(INSERT INTO Exception(access-li +st,acl-name,firewallID,Interface,server,Active) VALUES (?,?,?,?,?,Yes +))); # Build insert statement for the firewall table my $FWfirewallinst = $FWdb->prepare(q(INSERT INTO firewalls(FW-Name,Ty +pe,SW-revision,ContactID-PriWAN,ContactID-SecWAN,ContactID-ISSO) VALU +ES (?,PIX,?,2,3,1))); # Build query of the FirewalID assigned by the database my $FWfirewallqry = $FWdb->prepare(q(SELECT FirewallID FROM firewalls +WHERE FW-name = ?)) # The routine imports basic information about the firewall into the fi +realls table. # It assumes that the firewall is administratied by Foo and Bar by th +e WAN team, # and Baz in the ISSO. It returns the hostname of the firewall and the + FirewallID. sub nameimport { foreach (@_) { if (/hostname/) { local @name = split(/ /); } elsif (/version/) { local @version = split(/ /); }; }; $FWfirewallsinst->execute($name[1],$version[2]); $FWdb->commit; $FWfirewallsqry->execute($name[1]); @FWfirewallsinfo = $FWfirewallsqry->fetchrow_array; # print "$FWfirewallsinfo[0]\n"; return ($FWfirewallsinfo[0],$name[1]); } # The routine imports the acls into the Exception table. # It requires the $FWID global var is set to the FirewallID in the dat +abase. # The local var $aclimport keeps track of the number of successfully i +mported rules. # It assumes that all rules imported are active. Output is the number +of rules imported. sub acl { local $aclimport = 0; local $part = ""; foreach (@_) { if (/access-list/) { local @acl = split(/ /); foreach $part (@acl) { if ($part =~ /192\.35\.84\./) {local $server = $part}; }; local $interface = $acl[1] =~ s/acl-//; local @importinfo = (q($_,$acl[1],$FWID,$interface,$server +)); $FWexecptionins->execute(@importinfo) && $aclimport++; }; }; return scalar($aclimport); }; # If the firewall name has been supplied then get the FirewallID other +wise assume new config if (/$ARGV[1]/) { $FWfirewallsqry->execute($ARGV[1]); @FWfirewallsinfo = $FWfirewallsqry->fetchrow_array; my $FWID = $FWfirewallsinfo[0]; my $FWname = $ARGV[1]; } else { my ($FWID,$FWname) = nameimport(@config); }; my $aclimport = acl(@config); print "The script has successfully imported $aclimport rules for $FWna +me.\n";
I can't figure out what's wrong with my sub or my local declarations, can somebody shed some illumination on a poor novice?

Vec

In reply to What's wrong with my syntax? by vectorvillain

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.