#!/usr/bin/perl use strict; use warnings; $a = "12.2424.4812367"; $a =~ s/(?x) ( (?# match integer and floating point numbers ) (?: \d+ (?: \. \d+ )? ) ) ( (?# execute code, match result ) (??{ ## return twice the first argument sub{ shift() * 2 }->( $1 ) }) ) / ## print the arguments as a couple sub{ join( '', '(', shift(), ',', shift(), ')' ) }->( $1, $2 ) /ge; print $a; #### .