in reply to Re: XUL::Gui and Loop structure
in thread XUL::Gui and Loop structure

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

Replies are listed 'Best First'.
Re^3: XUL::Gui and Loop structure
by Jenda (Abbot) on May 31, 2011 at 18:24 UTC

    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)" :)