Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Replacing multiple spaces into one character?

by blakem (Monsignor)
on Oct 09, 2001 at 07:36 UTC ( [id://117637]=note: print w/replies, xml ) Need Help??


in reply to Re: Replacing multiple spaces into one character?
in thread Replacing multiple spaces into one character?

you could also use the magical ' ' (single space) arg to split, which will remove leading spaces as well...
#!/usr/bin/perl -wT use strict; my $str =' Perlmonks is a very cool place '; $str = join '_', split ' ', $str; print $str, "\n"; =OUTPUT Perlmonks_is_a_very_cool_place

-Blake

Replies are listed 'Best First'.
Re: Re: Re: Replacing multiple spaces into one character?
by tachyon (Chancellor) on Oct 09, 2001 at 07:47 UTC

    Thanks blakem that null string that you get using /\s+/is a pain. I never realised that ' ' was magical.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Yeah, its a little screwy. ' ' is magical, but / / is not. I admit to checking the docs on occasion to remember which one is which.

      -Blake

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-24 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found