On 9/1/11 Thu Sep 1, 2011 5:15 PM, "Rajeev Prasad" <rp.ne...@yahoo.com> scribbled:
> tried further, still no resolution: Please use complete sentences in your posts. You are asking people to help you for free, so please give them the courtesy of using proper language. > > file1 = (space seperated values) > outputfile = (colum1, and 5 onwards) field seperator would be space. > > from linux: cut -f1,5- -d" " file |grep -v "^0" | sort -n > to_file; > > > open(tmpFH,"<","file1"); > @tmpAR = <tmpFH>; > close(tmpFH); > foreach $line (@tmpAR) { > @tmpAR2 = split(/ /,"$line"); There is no need to surround $line with double-quotes: @tmpAR2 = split(/ /,$line); Note that the split will delete the newline character from the last element of @tmpAR2. > $line2 = "$tmpAR[0] $tmpAR[5..-1]"; The range [5..-1] is empty, since -1 is less than 5. You need to use the last index value here. Also, since an array slice is an array, it should use the '@' sigil, not the '$' for scalars. You can also add back the newline: $line2 = "$tmpAR[0] $tmpAR[5..$#tmpAR]\n"; > push(@tmpAR3,$line2); > }; > @tmpAR3 = sort(@tmpAR3); > print @tmpAR3; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/