change my ( $age, $gender, $address ) = split /,/, $rest; to my ($address) = (split /,/, $rest)[-1]; or my ($address) = (split /,/, $rest)[2];