$str="www,google,yahoo,345"; my ($var1,$var2)= $str =~/^([^\n]+),([^\n]+)$/;