Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a few checkboxes on a form. I am trying to convert the ticked checkbox to 'yes', unchecked to 'no'.
I thought I could do the following:
But actually changes all $item to 'yes'my @array = qw($one $two $three); foreach my $item (@array){ if ($item) { $item = 'yes'; } else { $item = 'no'; }
Could anyone tell me what I am doing wrong and how I might achieve these chqnges.
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Changing each item in an array
by diotalevi (Canon) on Jul 18, 2003 at 23:34 UTC | |
by Limbic~Region (Chancellor) on Jul 19, 2003 at 00:03 UTC | |
by diotalevi (Canon) on Jul 19, 2003 at 00:12 UTC | |
|
Re: Changing each item in an array
by Abigail-II (Bishop) on Jul 19, 2003 at 11:11 UTC | |
|
•Re: Changing each item in an array
by merlyn (Sage) on Jul 18, 2003 at 23:54 UTC | |
|
(jeffa) Re: Changing each item in an array
by jeffa (Bishop) on Jul 19, 2003 at 01:42 UTC | |
|
Re: Changing each item in an array
by bobn (Chaplain) on Jul 18, 2003 at 23:39 UTC | |
|
Re: Changing each item in an array
by Jenda (Abbot) on Jul 19, 2003 at 18:10 UTC |