S
Spydo
Hello experts:
Honestly it's very unusual that I can't figure out a tite lil' regex
to solve a substitution, but this one has me baffled.. And it looks
simple..
I'm trying to remove ALL but the last dot in a scalar.
So I want to replace
'cat.dog.mouse.eel.txt'
with
'catdogmouseeel.txt'
I've tried a bunch of approaches, and one actually WORKS but has
warnings...
WORKS but throws warnings seemingly for every extra dot:
s/\.(?=[^\.]*\.)/$1/g;
DB<7>
Use of uninitialized value in substitution iterator at x.pl line 5.
at x.pl line 5
Use of uninitialized value in substitution iterator at x.pl line 5.
at x.pl line 5
Use of uninitialized value in substitution iterator at x.pl line 5.
at x.pl line 5
DB<7> x
$_
0 'catdogmouseeel.txt'
DOES NOT WORK- Im not really sure why:
s/([^\.]*)\.?=(.*\.)/$1$2/g;
(does nothing)
Honestly it's very unusual that I can't figure out a tite lil' regex
to solve a substitution, but this one has me baffled.. And it looks
simple..
I'm trying to remove ALL but the last dot in a scalar.
So I want to replace
'cat.dog.mouse.eel.txt'
with
'catdogmouseeel.txt'
I've tried a bunch of approaches, and one actually WORKS but has
warnings...
WORKS but throws warnings seemingly for every extra dot:
s/\.(?=[^\.]*\.)/$1/g;
DB<7>
Use of uninitialized value in substitution iterator at x.pl line 5.
at x.pl line 5
Use of uninitialized value in substitution iterator at x.pl line 5.
at x.pl line 5
Use of uninitialized value in substitution iterator at x.pl line 5.
at x.pl line 5
DB<7> x
$_
0 'catdogmouseeel.txt'
DOES NOT WORK- Im not really sure why:
s/([^\.]*)\.?=(.*\.)/$1$2/g;
(does nothing)