#!/usr/bin/perl -w use strict; my $string = "foo.bar.foobar"; my ($val1,$val2) = (split /\./,$string)[-2,-1]; print "$val1,$val2\n";