Sorry, misinterpreted your intent. This should work to split it that way then: #!/usr/bin/perl -w
use strict;
my $string = "foo.bar.foobar";
my ($val1,$val2) = split /\.(?!.*\.)/,$string;
print "$val1,$val2\n";
update:and another way: #!/usr/bin/perl -w
use strict;
my $string = "foo.bar.foobar";
my $position = rindex($string,'.');
my ($val1,$val2) = (
substr($string,0,$position++),
substr($string,$position)
);
print "$val1,$val2\n";
update:Apparently, I suffer from not enough laziness, as in the end would probably have kept thinking there has to be a more elegant solution, and would hopefully stumbled upon sauoq's solution below at some point, which I think is the best solution, but leave the above code if only to show TMTOWTDI.
-enlil |