[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Loop question



     ###   Hi Timothy,
     ###      you are right to do it in one line.
     ###      But that one line can be considerably
     ###      shorter, because there is no need to
     ###      care for arrays shorter than 8 elements.
     ###      So the script is slimmed down to 18 chrs.

     ### Test data:

@whole = (
"first line\n", "second line\n", "third line\n", "fourth line\n",
"fifth line\n", "sixth line\n", "seventh line\n", "eightth line\n",
"nineth line\n", "tenth line\n", "eleventh line\n", "twelveth line\n");

     ### The script:

print @whole[0..7]

     ###  Do you agree? (Bruce already mentioned it.)
     ###
     ###  Detlef Lindenthal <detlef@lindenthal.com>



#> Tomothy wrote:
#>    If you know that each line is terminated by a return,
#>    you should be able to get away with...

#>  print join("",@whole[0..($#whole>7 ? 7 : $#whole)]),"\n";




# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org