Dr.Ruud said:
For example (and I'm only an amateur at this), the C structure for an
"if" statement translates to Perl as this:
[... The code was removed, but why? ...]
A far better example would be something, where there is no analog
construct in C, e.g. a foreach loop.
foreach my $elem (@list) {
process($elem);
}
I don't see what is 'far better' here. A while on an iterator would be
very similar in C.
I respectfully disagree. The point is that in C you cannot access the
elements of an array or list without using an explicit index which means
you have to iterate (i.e. explicitely initialize, increment, and
terminate) over that index.
Therefore the difference is between
"with each element of the list do foobar()"
and
"initialize $i to start index;
as long as $i is smaller than the end index
{do foobar() with element array[$i] and increment $i}
To me it is a very major difference if I have to invent and maintain an
auxiliary index variable or not.
An even more perlish alternative;
process($_) for @list;
This is where _I_ would ask what is the difference to
foreach (@list) {process ($_)};
jue