Hi all, I am a Perl noob. I will admit that here right away. Any pointers here would be helpful. I am trying to build a little menu for Ethernet switch configurations.

#!/usr/bin/perl -w # use warnings; use diagnostics; use warnings; use strict; use Term::ANSIScreen qw(cls); our @switches; our $clear_screen = cls(); # Subroutine vars our $slotcount = 1; ###################### START of MENU 1 / MODEL SELECT ############### +#### while (my $modelselect ne '10') { print $clear_screen; print "########################################################### +##########\n"; print "## Configuration Script for Catalyst Access Switches IOS + 15.x ##\n"; print "########################################################### +##########\n"; print "## + ##\n"; print "##  Select Model of Switch: + ##\n"; print "## (1) - Cat6509 (2) - Cat6506 (3) - Cat6513 + ##\n"; print "## (2) - Cat4507 (5) - Cat4506 (6) - Cat4510 + ##\n"; print "## (7) - WS-C3850-24 (8) - Cat3850-48 (9) - Cat3850 +Stack ##\n"; print "## (10) - Exit + ##\n"; print "## + ##\n"; print "########################################################### +##########\n"; print "Please enter your selection:\n"; $modelselect = <STDIN>; chomp $modelselect; if ($modelselect eq 1) { print "You have selected $modelselect\n"; my $slotlimit = 9; print "You have selected a 'WS-C6509'.\n"; print "$slotlimit lincecard slots have to be configured:\n +"; while ($slotcount <= $slotlimit) { print "Calling Subroutine 'Slotmenu' with value $s +lotcount\n"; &slotmenu($slotcount); push (@switches, my $portcount); $slotcount++; } } if ($modelselect eq 2) { print "You have selected $modelselect\n"; my $slotlimit = 6; print "You have selected a 'WS-C6506'.\n"; print "$slotlimit lincecard slots have to be configured:\n +"; while ($slotcount <= $slotlimit) { print "Calling Subroutine 'Slotmenu' with value $s +lotcount\n"; &slotmenu($slotcount); push (@switches, my $portcount); $slotcount++; } } print "@switches\n"; sub slotmenu { print $clear_screen; print "Value actually passed to Subroutine 'Slotmenu': $slotcount\ +n"; print "########################################################### +##########\n"; print "## Configuration Script for Catalyst Access Switches IOS + 15.x ##\n"; print "########################################################### +##########\n"; print "## + ##\n"; print "## Configure Slot $slotcount: + ##\n"; print "## Select port count, speed, or other layout + ##\n"; print "## + ##\n"; print "## 1000 Mbit/s = (A) 10000 Mbit/s = (B) + ##\n"; print "## 24 X Blade = (1) 48 x Blade = (2) + ##\n"; print "## Supervisor = (S) + ##\n"; print "## No linecard = (0) + ##\n"; print "## + ##\n"; print "## 'Enter as: A2 for 48 x 1000 Mbit lincecard + ##\n"; print "## + ##\n"; print "########################################################### +##########\n"; print "Please enter number ports on linecard:\n"; my $portcount = <STDIN>; chomp $portcount; #return $portcount; push (@switches, $portcount) } }

I keep getting this strange output when i run this script:

Use of uninitialized value $switches[1] in join or string at morecurre +nt.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[3] in join or string at morecurre +nt.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[5] in join or string at morecurre +nt.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[7] in join or string at morecurre +nt.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[9] in join or string at morecurre +nt.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[11] in join or string at morecurr +ent.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[13] in join or string at morecurr +ent.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[15] in join or string at morecurr +ent.pl line 69, <STDIN> line 11 (#1) Use of uninitialized value $switches[17] in join or string at morecurr +ent.pl line 69, <STDIN> line 11 (#1) A1 B1 B12 S S S S S S Use of uninitialized value $modelselect in string ne at morecurrent.pl + line 19, <STDIN> line 11 (#1)
Thank you in advance. - Georg

In reply to Strange undefined scalars in array by GeorgMN

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.