: Foreach is more intuitive than map for me. If the array is long, however,
: speed would be important. Is map faster? And finally, can someone tell me
: why my original mangled the array? It looks logical enough to me. My version
: of Perl is 5.004_04 built for sun4-solaris.
This is the original code:
#!/usr/local/bin/perl -w
use strict;
my ($element,$item);
print "$item times $element\n";
Quote:
}
}
its results array and element at each loop of foreach
0 1 2 3
a times b
a times c first loop of foreach : $element = $array[0];
a times d
0 1 2
c times c
c times d second loop of foreach : $element = $array[1];
0 1
third loop of foreach : $element = $array[2];
and the array no longer even has such an element.
--thelma
: Bob
: ********************
: Robert Gwynne, Ph.D.
: Speech Communication
: University of Tennessee, Knoxville
: http://www.*-*-*.com/ ~gwynne
: 423-523-1097 Home
: 423-974-6836 Office
: 423-974-4879 Fax
: ***********************************
: Liberalism has always derived its authority and persuasiveness from a vision
: of human nobility, from the idea that our dignity is derived from the
: exercise of m{*filter*}choice. M{*filter*}absolutism fears this act of choice and
: fears the freedom required by the act of choosing.
: Liberalism depends, ultimately, on faith in human choosing, and a liberal
: revival depends on recovering the inspiration of this central conviction.
: Michael Ignatieff