in reply to Changing each item in an array
Your @array variable contains three strings: '$one', '$two', and '$three'. Try it again as my @array = ($one, $two, $three). And pick better names. Those are atrocious and are absolutely uncommunicative about their purpose.
Added: I should mention that doing things this way means the copy of the value in @array is now altered, the original contents of $one, $two and $three will remain unaltered. You need references to alter the original variables. Your code then looks like this:
my @array = ( \ $one, \ $two, \ $three); foreach my $item (@array){ if ($$item) { $$item = 'yes'; } else { $$item = 'no'; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Changing each item in an array
by Limbic~Region (Chancellor) on Jul 19, 2003 at 00:03 UTC | |
by diotalevi (Canon) on Jul 19, 2003 at 00:12 UTC |