Re: More loops
- From: Jenda@xxxxxxxxxxx (Jenda Krynicky)
- Date: Thu, 28 Jun 2007 15:30:19 +0200
From: "Chas Owens" <chas.owens@xxxxxxxxx>
On 6/28/07, Jenda Krynicky <Jenda@xxxxxxxxxxx> wrote:
From: "Amichai Teumim" <amichai@xxxxxxxxxx>snip
snipforeach $elem (@array){
print "$elem\n";
}
This can be simplified to
print join("\n", @array), "\n";
or (since this is Perl and TIMTOWTDI)
print map { "$_\n" } @array;
or
print "$_\n" for @array;
or (and all beginners should close their eyes since I'm going dirty
now)
{ local $" = "\n";
print "@array\n";
}
or
{ local $, = "\n"; local $\ = "\n";
print @array;
}
or
{ local $\ = "\n";
print for @array;
}
Hello Tim, how's missis Toady? ;-)
Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
.
- Follow-Ups:
- Re: More loops
- From: Chas Owens
- Re: More loops
- References:
- More loops
- From: Amichai Teumim
- Re: More loops
- From: Jenda Krynicky
- Re: More loops
- From: Chas Owens
- More loops
- Prev by Date: Re: parsing a line
- Next by Date: Re: parsing a line
- Previous by thread: Re: More loops
- Next by thread: Re: More loops
- Index(es):
Relevant Pages
|
|