--- Peter Cornelius <[EMAIL PROTECTED]> wrote:
> A cool control structure in perl is the for or foreac loop.  With it
> you don't need to know the size of the array you can just
>    for my $thing (@A) {
>       #do stuff with $thing
>    }

This is very efficient; just keep in mind that $thing is actually
aliased to each element of @A in turn, so changing $thing actually
changes @A. Also, *always* (if you can) use this in preference to the C
syntax of
 for($i=0;$i<$x;$i++) {}

It's faster and more efficient, doesn't require as many vars, and looks
more Perl-ish. =o)
 
> If you're familiar with shell syntax this is kinda like the 'for i in
> list' construct.

Just be aware that it's *aliasing*, ~not~ making a copy!

=====
print "Just another Perl Hacker\n"; # edited for readability =o)
=============================================================
Real friends are those whom, when you inconvenience them, are bothered less by it than 
you are. -- me. =o) 
=============================================================
"There are trivial truths and there are great Truths.
 The opposite of a trival truth is obviously false.
 The opposite of a great Truth is also true."  -- Neils Bohr

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to