Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Code Works But Not Sure How

by johngg (Abbot)
on Feb 11, 2018 at 11:44 UTC ( #1208946=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1208946]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2018-07-21 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (448 votes). Check out past polls.

    Notices?