> English to perl translation:
s/SID/12345/ for values %foo;
Nice - this takes advantage of the fact that $_ here is a reference to the
actual value of the hash so that the subst. works directly on the hash.
The same fact works for arrays too
@foo = ('abc/SID/def', 'bcd/SID/fgh', 'hjk/SID/opq' );
foreach ( @foo ) {
s/SID/12345/;
}
or:
s/SID/12345/ for @foo;
It's also a cautionary tale - if you're using the default "$_" in for
loops, you can munge your original data.
foreach my $foo ( @foo ) {
$foo =~ s/SID/12345/;
}
this doesn't mess w/ @foo.
a
Andy Bach
Systems Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738 FAX 264-5932
Remember, the first rule of optimisation is: don't do it yet. :-) Brian
Raven
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs