Re: More loops

2007-06-28 Thread Chas Owens
On 6/28/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote: From: "Chas Owens" <[EMAIL PROTECTED]> > On 6/28/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > > From: "Amichai Teumim" <[EMAIL PROTECTED]> > snip > > > foreach $elem (@array){ > > > print "$elem\n"; > > > } > > > > This

Re: More loops

2007-06-28 Thread Jenda Krynicky
From: "Chas Owens" <[EMAIL PROTECTED]> > On 6/28/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > > From: "Amichai Teumim" <[EMAIL PROTECTED]> > snip > > > foreach $elem (@array){ > > > print "$elem\n"; > > > } > > > > This can be simplified to > > > > print join("\n", @array), "

Re: More loops

2007-06-28 Thread Chas Owens
On 6/28/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote: From: "Amichai Teumim" <[EMAIL PROTECTED]> snip > foreach $elem (@array){ > print "$elem\n"; > } This can be simplified to print join("\n", @array), "\n"; snip or (since this is Perl and TIMTOWTDI) print map { "$_\n" } @array; -- To

Re: More loops

2007-06-28 Thread Jenda Krynicky
From: "Amichai Teumim" <[EMAIL PROTECTED]> > I need to use two loops and an if statement to sort the contents of > this array so > that the number go from lowest to highest. @sorted = sort {$a <=> $b} @unsorted; You can use the builtin function sort(). All you have to do is to tell it how do you

More loops

2007-06-28 Thread Amichai Teumim
I need to use two loops and an if statement to sort the contents of this array so that the number go from lowest to highest. #!/usr/bin/perl @array = (5,3,2,1,4); ## include your code here ## foreach $elem (@array){ print "$elem"; } Looking further into this it was revealed to me that I shou