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

Re: Incredibly stupid substitution question :(

by biohisham (Priest)
on Aug 11, 2010 at 07:28 UTC ( [id://854249]=note: print w/replies, xml ) Need Help??


in reply to Incredibly stupid substitution question :(

One regex-less way to do this is to split around the (.) into an array and join the elements back;
use strict; use warnings; my $string = "Kev.has.a.stupid.perl.question"; my @array = split /\./, $string; my $fixed = join('\.',@array); print $fixed;
Though, your regex $text =~ s/\./\\./g; seems to can work fine!.

update: added links and a bit of details


Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

Replies are listed 'Best First'.
Re^2: Incredibly stupid substitution question :(
by JavaFan (Canon) on Aug 11, 2010 at 09:03 UTC
    One regex-less way to do this is to split
    Uhm, you do know split, don't you? And you do know the type of its first argument, don't you?

    Indeed, you do. Your "regexp-less" way uses the same regexp as you're trying to avoid. All you did was to move the regexp from s/// to split. You "regexp-less" way does not use less regexpes, or even a simpler one.

Re^2: Incredibly stupid substitution question :(
by wwe (Friar) on Aug 11, 2010 at 07:50 UTC
    the original regex didn't worked on my system too. I'm using Strawberry Perl 5.10 on WinXP.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found