TomC wrote:
>In general, getting folks to write
>
> s/^\s+//s;
> s/\s+$//s; # XXX: \z
>
>is a *good* think.
Why?
Removing leading/trailing whitespace is a tremendously frequently-
performed task. Perl gives you -l on the command line to strip
newlines on input and add them on output, simply because that's
what you need to do, very often.
Perl allows you to glomp your input one "paragraph" at a time,
by setting $/ to "", because it's quicker and more convenient than
searching for the pattern /\n{2,}/, and because people often want
to do that.
I'm not arguing in favor of the tr/// hack specifically, but
gosh, wouldn't it be nice if there were a thwack() builtin that
stripped leading and trailing spaces?
while (<>)
{
chomp;
thwack; # or whatever
barf if /^barf/;
last if /!!$/;
print LOG "$_ found\n";
}
----------------------------------------------------------------------
Eric J. Roode, [EMAIL PROTECTED] print scalar reverse sort
Senior Software Engineer 'tona ', 'reh', 'ekca', 'lre',
Myxa Corporation '.r', 'h ', 'uj', 'p ', 'ts';