ropey has asked for the wisdom of the Perl Monks concerning the following question:
Could someone explain to me what causes this behaviour ?
#!/usr/bin/perl -w use strict; my @subs = ("_iata_city"); foreach my $sub(@subs) { $sub =~ s/^_//g; print $sub;; } foreach my $sub(qw/_iata_city/) { $sub =~ s/^_//g; print $sub;; }
1) First loop = iata_city
2) Second loop = Modification of a read-only value attempted
I am assuming it has something to do with the _ in the qw// but am not sure why ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Modification of a read-only value attempted
by kyle (Abbot) on Dec 03, 2008 at 14:23 UTC | |
|
Re: Modification of a read-only value attempted
by almut (Canon) on Dec 03, 2008 at 14:25 UTC | |
|
Re: Modification of a read-only value attempted
by Anonymous Monk on Dec 03, 2008 at 14:19 UTC |