--- Lysander <[EMAIL PROTECTED]> wrote:
> I need to replace all the occurances of one thing
> with another. This is simple enough, except that
> I am working with a list variable, rather than a
> scalar...
list != array (and you mean an array)
>
> for my $body (@body)
> {
> $body =~ s/foo/bar/;
> }
>
> appears to leave @body empty.
Err... tested and words fine.
> How does one go about this?
s/foo/bar/ for @body;
Note: Don't use "for" when iterating over an array, unless
it reads better - use "foreach". I'd suggest you use it
like I have, or:
for ($var) {
s/foo/bar/;
}
when you aren't really working with an array.
Jonathan Paton
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]