print "r,b,swpd,free,buff,cache,si,so,bi,bo,in,cs,us,sy,id,wa,st,\n"; while(<>){ if(/\d/){ chomp; $_ =~ s/\t//; @array = split / /, $_; foreach(@array){ if($_ =~ /.+/){ print; print","; } } print "\n"; } }