What's the difference between 'for' and 'foreach' in Perl?

for-loop, foreach, loops, perl, syntax

Solution

There is no difference. From perldoc perlsyn:

The `foreach` keyword is actually a synonym for the `for` keyword, so you can use `foreach` for readability or `for` for brevity.

Problem

I see these used interchangeably. What's the difference?

Original source

Related problems