On 1/19/06, Gladstone Daniel - dglads <[EMAIL PROTECTED]> wrote:
> What would be the simplest way to remove leading and trailing blanks
> from a user input?
>
> Daniel Gladstone ([EMAIL PROTECTED])
snip
One easy way to do it would be to use a regex:
#!/usr/bin/perl
$input = <>;
chomp($input);
print "[$input]\n";
$input =~ s/ #replace
^\s* #all whitespace at the front
(.*?) #all of the stuff in the middle
\s*$ #all whitespace at the end
/$1/x; #with the stuff in the middle
print "[$input]\n";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>