The following sort-code came from an old CPAN page. It seems to work just fine (it sorts a tab-delimited text file by the 3rd column), but if I have warnings (-w) turned on the compiler throws a whole bunch of "Use of uninitialized value" warnings about the line that starts "@newrefs ....". What's wrong?
open(FILE, $file) || die("Couldn't open $file: $!\n"); @content = <FILE>; close(FILE); @listrefs = map { [$_, (split(' ', $_))[2] ] } @content; @newrefs = sort { $a->[1] <=> $b->[1] } @listrefs; @content = map { $_->[0] } @newrefs; Thanks for all the help so far, this list is great! - B ____________________________ > I suppose it does look a little bizarre. Actually, my goal is a little > more complex. We have a simulation that outputs data files, but often up > to 90% of the data is redundant. So I'm trying to write a filter for the > data. I have to: > > 1. open and load the file > 2. strip all comments (marked with a #) and blank lines off the top > 3. sort by column 4, then by column 3 > 4. remove all lines at the top that have a 0 in column 5 > 5. write the comments + sorted lines back out to a new file > > Unfortunately I'm new enough at perl that I've only got steps 1 and 2 to > work so far... I got some great help here on the list for step 3, though > the code at <URL> > seems much more concise. I just haven't gotten it to work on my array > instead of a string. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]