
substitute a string in array
Quote:
>I'm reading a file into an array then splitting it:
^^^^^^^^^^^^^^
You can substitute in a scalar ($_) _before_ you split it into the array.
You substitute in a scalar with the s/// operator.
Quote:
>I need to substitute a string in that array,
If you _did_ need to substitute in an array, you can do that with
the aliasing feature of the foreach loop:
# s/// as below
}
When you modify the loop control variable ($_ in this case),
the modification is made back in the array being foreach'd.
Read about foreach loops with:
perldoc perlsyn
Quote:
>such string like " > " to be
>substituted with " > ".
If what you are really doing is escaping HTML entities, then
you should use a module that does that.
Assuming that you are NOT escaping entities and just want
to do a substitution:
s/ > / > /g;
will do it.
Quote:
>Tried to look in newsgroups and online without
>good help.
The s/// operator is documented on your very own hard disk:
perldoc perlop
and the regular expressions that the operator uses are described here:
perldoc perlre
--
Tad McClellan SGML consulting
Fort Worth, Texas