http://en.wikipedia.org/wiki/Trim_%28programming%29
$string =~ s/^\s+//; # remove leading whitespace $string =~ s/\s+$//; # remove trailing whitespace or $string =~ s/^\s+|\s+$//g ; # remove both leading and trailing whitespace On Tue, May 10, 2011 at 10:25 AM, Irene Zweimueller <irene.zweimuel...@univie.ac.at> wrote: > Dear list, > > I´m relatively new to Perl, so please be patient. > > I tied to get rid of whitespace characters by the following programme: > > my $i=" USEFUL "; > > > if ($i =~ /\s/) > { > $i =~ s/\s*//; > } > > print "xxxxxxxxxx $i xxxxxxxxxx\n"; > > and it removes the whitespace characters in front of USEFUL, but not those > behind.. > Any suggestions? > > kind regards > Irene Zweimueller > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/