$str=" this is a string example"; @data= ( $str =~ /(.*?\n)/g ); print map "[$_]",@data ; #### [ ][this ][is ][a string ]