The idea is really to count the lines, This will run in a test and
seems to me the most clear code.

the original code is +-:
is( scalar( split( /\n/, $trap->stdout ) ) ), 15);

The lines have no special order.

Best Regards
Marcos Rebelo

On Fri, Jul 9, 2010 at 3:42 PM, Chas. Owens <chas.ow...@gmail.com> wrote:
> On Fri, Jul 9, 2010 at 09:22, Chas. Owens <chas.ow...@gmail.com> wrote:
> snip
>> {
>>    my @temp = split /\n/, "first\nsecond\nthird";
>>    xpto @temp;
>> }
> snip
>
> Or you use the [CountOf secret operator][1] to count the number of
> items split returns, but not well the use of a -1 limit on the split.
> If you don't provide a negative limit, then split will optimize itself
> for returning to an empty list and the result will be 1 regardless of
> the input (well, an empty string will still return 0).
>
> xpto( ()= split /\n/, "first\nsecond\nthird", -1 );
>
>  [1]: http://cowens.github.com/perlopquick/perlopquick.html#()=-X
>
> --
> Chas. Owens
> wonkden.net
> The most important skill a programmer can have is the ability to read.
>



-- 
Marcos Rebelo
http://oleber.freehostia.com
Milan Perl Mongers leader http://milan.pm.org
Webmaster of http://sites.google.com/site/oleberperlrecipes/

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to