In your first block of code you are modifiying the element of the array which is what you expect I believe. In your second block of code you are modifiying a new variable set at first equal to the value of the array element and then modified using the substition. The modification is not touching th
ittwer
Sent: Saturday, May 08, 2004 11:33 AM
To: ActiveState
Subject: Array behavior: please expalin ...
Hi,
I thought I know a bit of perl but this is confusing ...
=== cut 1 ===
#! /usr/bin/perl
use strict;
my @ar = ();
push @ar,"Harry Fred Paul";
push @ar,"Fred Ringo John&
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Andreas Karl Wittwer
Sent: Saturday, May 08, 2004 2:33 PM
To: ActiveState
Subject: Array behavior: please expalin ...
Hi,
I thought I know a bit of perl but this is confusing ...
=== cut 1 ===
#! /usr/bin/perl
use strict;
my @ar = ();
pu
Hi,
I thought I know a bit of perl but this is confusing ...
=== cut 1 ===
#! /usr/bin/perl
use strict;
my @ar = ();
push @ar,"Harry Fred Paul";
push @ar,"Fred Ringo John";
push @ar,"Georg Don Fred";
foreach my $l (@ar) {
$l =~ s/Fred/Thomas/;
}
t();
sub t {
for(my $z=0;$z<@ar;$z