Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: How to remove underscore before every dot using perl?

by Athanasius (Bishop)
on Mar 16, 2017 at 07:05 UTC ( #1184835=note: print w/replies, xml ) Need Help??

in reply to How to remove underscore before every dot using perl?

Hello finddata,

For the transliteration operator, the /c modifier complements the searchlist, and the /d modifier causes found-but-not-replaced characters to be deleted. So the expression tr/a-zA-Z//dc says: Delete any character that is not a letter. But that includes the dot. So you need to add in a dot, to say: Delete all characters except letters and dots:

$str =~ tr/a-zA-Z.//dc;

But in this case I think it would be clearer to use an explicit substitution:

$str =~ s/_\././;

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2020-02-28 11:58 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (123 votes). Check out past polls.