in reply to difficulty in sorting
I find changing $/ to be too confusing. That's not to say that it can't be used to good effect, only that it's easier to read usually when you don't. So, here goes:
It seems to get the job done. Of course, I'm assuming that all the ref lines are in a row.#! /usr/bin/perl -w use strict; my @sortable; while ( <DATA> ) { # are we in the ref's? if (/^\<ref/) { # keep track of it, but don't print it out yet. push @sortable, $_; next; } # else, are we done ref's? if (@sortable) { print for sort @sortable; # done with them, get rid of 'em. @sortable = (); } # this line can be printed out at this point. print; } __DATA__ [ same as yours, so I'm not repeating it ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: difficulty in sorting
by texuser74 (Monk) on Aug 21, 2008 at 05:40 UTC | |
by RMGir (Prior) on Aug 21, 2008 at 09:21 UTC |