http://www.perlmonks.org?node_id=1208946


in reply to Code Works But Not Sure How

If you are numbering your menu items upwards from '1' this might be a simpler way to initialise your options.

use strict; use warnings; use feature qw{ say }; my @options = ( q{Option 1}, q{Option 2}, q{Option 3}, q{Option 4}, ); my $ct; @options = map { ++ $ct; qq{'$ct'}, qq{'$_'} } @options; say for @options;

The output.

'1' 'Option 1' '2' 'Option 2' '3' 'Option 3' '4' 'Option 4'

I hope this is of interest.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Code Works But Not Sure How
by RichHamilton (Novice) on Feb 11, 2018 at 14:15 UTC
    Yes, I'm interested in this. At my skill level map examples are very helpful. Thanks!