$str="www,google,yahoo,345"; my ($var1,$var2)=split(/,/,$str); Output: $var1=www $var2=google