
japhy
Enthusiast
Feb 13, 2000, 8:28 AM
Post #3 of 3
(509 views)
|
The idiom for changing an element in an array is" <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> for (@array) { if (CONDITION) { # modify $_ } } </pre><HR></BLOCKQUOTE> You don't need to use a counter variable, or refer to $array[..]. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> for (@array) { if (length > 50) { # if the element is more than 50 characters substr($_, 47, 3, "..."); # make the last three characters "..." } } </pre><HR></BLOCKQUOTE>
|