foreach $line () { chomp $line; ($package, $ver) = split /-(?=[^-]+(-r[0-9]+)?$)/, $line; print "$package ==> $ver\n"; }