in reply to Re: Re: hashes of arrays
in thread hashes of arrays
The output was:#!/usr/local/bin/perl use strict; my @array = ('one', 'two', 'three'); for my $element (@array) { $element = uc($element); } for my $element (@array) { print "$element\n"; } exit;
In this regard the for does in fact seem to be synonymous with foreach. In the extent that the elements of the array are changed both function the same.
But I must admit that by programming habit and for the sake of readiblity I adhere to the convention:
foreach loop to change the contents of an array
"for" when I'm not.
In spite of my habits and preferences apparently they both work the same. But alas my C background has me using for when I'm just stepping through array indexes.
|
|---|