in reply to what is the function should I need to use for trim white spaces ?

> Hi Gr8 People

Please don't use those kinds of abbreviations. There are people speaking many languages who come here and there's no point in making things harder for them to understand.

> Is there any other built in function available to do the stuff.

No, the way you showed is the best way (except you don't need the "g" since you already get all the spaces with "+").

  • Comment on Re: what is the function should I need to use for trim white spaces ?

Replies are listed 'Best First'.
Re^2: what is the function should I need to use for trim white spaces ?
by davido (Cardinal) on Jan 11, 2006 at 19:24 UTC

    I thought about this too. You're correct that the /g modifier is kind of pointless by itself, but combined with the /m modifier, you get improved functionality (for some definitions of 'improved'):

    use strict; use warnings; my $string = " now is the \ntime for all \n good men to co +me \n to the aid\n"; $string =~ s/^\s+//mg; $string =~ s/\s+$//mg; print $string, "\n";

    Dave