Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: XUL::Gui and Loop structure

by lancer (Beadle)
on May 31, 2011 at 07:23 UTC ( #907405=note: print w/ replies, xml ) Need Help??


in reply to XUL::Gui and Loop structure

Try this:

#!/usr/bin/perl use XUL::Gui; $moreThanOne=5; sub build_list { my $howmany = shift; my @list = (); for(my $i = 0, $imax = $howmany; $i <= $imax; $i++) { push @list, Label (value=>$i); } return @list; } @pacientes = build_list $moreThanOne; display Window title => "Pacientes", width => 640, height => 480, Grou +pBox (@pacientes);


Comment on Re: XUL::Gui and Loop structure
Download Code
Re^2: XUL::Gui and Loop structure
by sagus (Initiate) on May 31, 2011 at 15:55 UTC
    Thank you!! :) This was just I need =)
      Your welcome! I'm glad it was helpful! :)
Re^2: XUL::Gui and Loop structure
by Argel (Prior) on May 31, 2011 at 16:47 UTC
    Why the C-style for loop? More Perlish to use the '..' operator.
    #!/usr/bin/perl use XUL::Gui; $moreThanOne=5; sub build_list { my $howmany = shift; my @list = (); push @list, Label(value=>$_) for 0 .. $howmany; return @list; } @pacientes = build_list $moreThanOne; display Window title => "Pacientes", width => 640, height => 480, Grou +pBox (@pacientes);
    UPDATE: The original post was edited. The code in this thread (one started by lancer) is based on the original code.

    Elda Taluta; Sarks Sark; Ark Arks

      If you want to be more Perlish, drop the @list.

      sub build_list { my $max = shift(); return map Label(value=>$_), 0..$max; }

      The name $howmany was misleading, you were generating more items than that as you were stargin with zero. And now there's little reason to keep on using a subroutine.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        "$howmany" can mean "how many pieces", but I understood it as "the value that lets you know how many (but not the answer itself)" :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://907405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-12-28 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls