GeorgMN has asked for the wisdom of the Perl Monks concerning the following question:
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:
Thank you in advance. - GeorgUse 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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange undefined scalars in arry
by BrowserUk (Patriarch) on Jan 13, 2014 at 14:17 UTC | |
|
Re: Strange undefined scalars in array
by Anonymous Monk on Jan 13, 2014 at 14:46 UTC | |
|
Re: Strange undefined scalars in array
by Preceptor (Deacon) on Jan 13, 2014 at 21:56 UTC | |
|
Re: Strange undefined scalars in array
by GeorgMN (Acolyte) on Jan 13, 2014 at 15:48 UTC |