For what it's worth, I made the code more Perlish and incorporated the fix proposed by the others:

use strict; use warnings; system 'cls'; Menu_Main( 10 ); sub Menu_Main { my ( $SWOS ) = @_; #$arr = Text to display, Menu position/selection#, Menu Section, +Numerical Reference my @arr = sort { $a->[ 1 ] <=> $b->[ 1 ] || $a->[ 2 ] <=> $b->[ 2 +] } $SWOS == 10 ? [ 'First', 8, 1, 27 ] : (), $SWOS == 10 ? [ '5x First', 13, 2, 28 ] : (), $SWOS == 10 ? [ 'Second', 9, 1, 29 ] : (), $SWOS == 10 ? [ 'Third', 10, 1, 30 ] : (), $SWOS == 10 ? [ '8x- Fourth', 21, 3, 31 ] : (), $SWOS == 10 ? [ '5x- Fifth', 17, 2, 32 ] : (), $SWOS == 10 ? [ '8x- First', 18, 3, 33 ] : (), $SWOS == 10 ? [ '8x- Second', 19, 3, 34 ] : (), $SWOS == 10 ? [ '5x- Fourth', 16, 2, 35 ] : (), $SWOS == 10 ? [ '8x- Third', 20, 3, 36 ] : (), $SWOS == 10 ? [ '5x- Second', 14, 2, 37 ] : (), $SWOS == 10 ? [ 'XXX- First', 23, 4, 38 ] : (), $SWOS == 10 ? [ 'Fouth', 11, 1, 39 ] : (), $SWOS == 10 ? [ 'Fifth', 12, 1, 40 ] : (), $SWOS == 10 ? [ '8x- Fifth', 22, 3, 41 ] : (), $SWOS == 10 ? [ '5x- Third', 15, 2, 42 ] : (); my @menu = ( '', '5x & 8x Series', '5x Series', '8x Series', 'Othe +r' ); my $menuidx = 1; print 'Select [1-' . @arr . "].\n\n$menu[$menuidx]\n"; for my $i ( 0 .. $#arr ) { if ( $arr[ $i ][ 2 ] != $menuidx ) { print "\t\t", '-' x 58, "\n$menu[$arr[$i][2]]\n"; $menu = $arr[ $i ][ 2 ]; } #print "\t\t$arr[$i][1]. $arr[$i][0]\n"; print "\t\t", $i + 1, ". $arr[$i][0]\n"; } print 'Selection ==> '; chomp( my $ANS = <STDIN> ); if ( $ANS < 1 || $ANS > @arr ) { warn "$ANS is not a valid menu selection.\n"; return; } # Print elements in array print 'Array count #1: ' . @arr . " \nProcessing ANS: $ANS\n"; my $MMANS = $arr[ $ANS - 1 ][ 3 ]; # Print Elements in array again print 'Array count #2: ' . @arr . " \nMMANS is: $MMANS\n"; }

In reply to Re: Count of element in array - Help by jwkrahn
in thread Count of element in array - Help by g_speran

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.