in reply to Replace all . with _ in a string

The obvious choice would be to use tr e.g
$_ = 'foo.bar(baz.quux)'; print "was: $_\n"; tr[.][_]; print "now: $_\n"; __output__ was: foo.bar(baz.quux) now: foo_bar(baz_quux)
See. the perlop manpage for more info.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Replace all . with _ in a string
by exussum0 (Vicar) on Dec 23, 2003 at 15:41 UTC
    And the regexp solution...

    ~s/\./_/g

    Just 'cause TMTOWTDI. And I am not claiming it's the best or worst solution :)


    Play that funky music white boy..