Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by jZed (Prior)
on Jan 11, 2006 at 19:17 UTC ( [id://522535]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://522535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-16 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found