Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: Code Works But Not Sure How

by poj (Monsignor)
on Feb 11, 2018 at 12:49 UTC ( #1208951=note: print w/replies, xml ) Need Help??

in reply to Re^2: Code Works But Not Sure How
in thread Code Works But Not Sure How

The items have their own associated array index so I don't see you really need to store sequential numbers as well

#!/usr/bin/perl package MyClass; use strict; use warnings; sub new { my $class = shift; my $self = { menu_items => _quote_items(shift), }; bless $self,$class; } sub _quote_items { my $ar = shift; $_ = "'$_'" for @$ar; return $ar; } package main; use strict; use warnings; use Data::Dumper; my @array = ('Option 0','Option 1','Option 2','Option 3','Option 4'); my $obj = MyClass->new(\@array); print Dumper $obj;

Replies are listed 'Best First'.
Re^4: Code Works But Not Sure How
by RichHamilton (Novice) on Feb 11, 2018 at 13:45 UTC
    You're right poj. In the code I use to create the menubox include the index as the menu items are a flattened array. I'm using a Linux Gazette bash script example and converting it over to perl. Basically its my own version of UI::Dialog.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2018-07-21 11:59 GMT
Find Nodes?
    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.