I'd suggest $scalar =~ s/^\s*//; $scalar =~ s/\s*$//; for that stuff... which'll get you of the hook for using dot-star. Death to Dot Star! is there for a reason, it's worth a moment of your meditation time :)
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.