How to Add dynamic array/hashes to Curses::UI:Listbox -lables

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hai Perl Curses:UI users,

I am new to perl and i am trying to develop an textmode application in
perl using Curses::UI
I can add a Curses:UI:Listbox widget to my application and it works

I read data from a text file and stored in to an array
the i try to use this array in Listbox but i failed.
my problem is that how i manage the options ( -values, -labels ) in
Should I use hashes or arrays?

Here is my code ie extracted from my original


#since am using unix machine

use strict;
use warnings;
use Curses::UI;

my $cui = new Curses::UI ( -clear_on_exit => 1, -color_support => 0);

my $win1 = $cui->add(
       'win1', 'Window',
       -title           => 'HEAD',
       -padtop          => 1, # leave space for the menu
       -border          => 1,
       -ipad            => 0,
       -bold            => 1,

my $kuricompfile="kuricomp.dat";
open(INP,$kuricompfile) || die "Cant open $kuricompfile" ;
my @companies=<INP>;

my $company;
my $counter=1;
my @myvalues;
my %myhash;

foreach $company (@companies)
@myvalues=keys %myhash;

my $comp_code = $win1->add(
       'comp_code', 'Listbox',
       -width     => 8,
       -y         => 1, -x => 17,
       -values    => @myvalues,
       -lables    => %myhash,

----------- code over here -------

when i run this code, perl gives me the following error message:

Can't use string ("4") as an ARRAY ref while "strict refs" in use at /
usr/local/lib/perl5/site_perl/5.8.6/Curses/UI/ line 264.

The data file kuricomp.dat contains the following data

1001  COMP.HEAD                      NEW.ADDRESS
1235  ANOTHER.COMP                   PLACE
1002  HELLO.IMP                      ADD1
1256  2563                           256

Kindly help me to correct the problem

Thanks in advance,


Re: How to Add dynamic array/hashes to Curses::UI:Listbox -lables

Quoted text here. Click to load it

I got the answer from comp.lang.perl.misc (muami) and this problem is

by changing these lines

        -values    => @myvalues,
        -lables    => %myhash,

       -values    => \@myvalues,
       -labels    => \%myhash,

Thank you muami,


Site Timeline