On Tue, 27 Nov 2001, Jorge Goncalvez <[EMAIL PROTECTED]> wrote, > Hi I have this: > > my $ip="192.40.54.41"; > > $ip=~ s/(\d+\.\d+)\.(\d+\.\d+)/$1\.0/; > > print $ip; > > But It didn't work it displays 192.40.0 and I wanted to display 192.40.54.0. > Why? thanks.
The first parentheses (refered to by $1) already contain 192.20. The first \d+ (one digit or more) matches 192, the \. matches the first ., and the second \d+ matches 40. So $1 contains "192.40". If you know exactly you'll change the the *last* sequence, you want to change only that. $ip =~ s/\d{1,3}$/0/; san -- Trabas - http://www.trabas.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]