On Aug 29, Roger Morris said:
>chomp $ucscode; # remove line-feed
>$ucscode =~ s/^\s+|\s+$//g; # remove spaces
>$scode=lc($ucscode); # make lower case.
Do not try to do this with one line, or one variable. Specifically, the
"remove whitespace" regex should be done it at least two steps.
$scode = lc $ucscode;
$scode =~ s/^\s+//;
$scode =~ s/\s+$//;
That's how I would write it. chomp()ing is pointless if you're removing
whitespace (assuming $/ is whitespace of some sort).
You could do the remove whitespace regex all at once, and even include the
lc() in there. I don't suggest it, though:
($scode = lc $ucscode) =~ s/\s*(\S*(?:\s+\S+)*)\s*/$1/;
But why you would to do that is beyond me. It is totally gross, and not
very maintainable without a couple comments explaining WHAT it does and
WHY you chose to do it that way.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]