substitute regex on arrays
John Evans
jtevans at kilnar.com
Thu Oct 17 17:34:24 CDT 2002
Heya guys,
Another question for ya. To strip leading/trailing spaces from a
string, do I typically do:
$s =~ s/^\s+//g;
$s =~ s/\s+$//g;
I need to do this on an array of strings, but the best solution that I
have is:
for ($cnt = 0; $cnt < @arr; ++$cnt) {
$arr[$cnt] =~ s/^\s+//g;
$arr[$cnt] =~ s/\s+$//g;
}
This works fine, but I'm wondering if there is a faster way of doing it?
Thanks!
--
John Evans
http://jtevans.kilnar.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s++:- a- C+++>++++ ULSB++++$ P+++$ L++++$
E--- W++ N+ o? K? w O- M V PS+ !PE Y+ PGP t(--) 5-- X++(+++)
R+++ tv+ b+++(++++) DI+++ D++>+++ G+ e h--- r+++ y+++
------END GEEK CODE BLOCK------
More information about the Pikes-peak-pm
mailing list