perl script to sort specific lines in a file

May 3, 2010 at 18:00:01
Specs: UNIX
I have a file that has the following format


.SUBCKT CELL4 1 2 3 4 ....
M1 2 3 4 5 ....
M3 4 2 5 6 ...
M0 3 4 6 9 4 ...
D1 9 4 5 ...
D2 9 0 2 cell1 ....
D0 3 5 6 cell2 ...
.ENDS

.SUBCKT CELL2 9 4 5 3 5 6 ....
M1 9 12 8 4 ....
M0 12 73 84 5 ...
D1 4 9 98 cell1 ...
D0 3 7 6 cell2 ...
.ENDS


I'm looking for a perl script that can sort the lines between SUBCKT and ENDS numerically based on the first column.


See More: perl script to sort specific lines in a file

Report •


#1
May 3, 2010 at 20:00:54
http://www.dayanahost.com/helpfiles...
also:
http://www.dayanahost.com/downloads...
has lots of other helps...

there's a "corny old saying" that i will afflict you with:
"give a man a fish: feed him for a day. Teach a man to fish: feed him till he's old and gray"
(of course, that might refer to his complexion after eating the wrong ones!)
( i warned you! corny! hell, i'm from west virginia - sorry!)


Report •

#2
May 3, 2010 at 23:30:25
due to time constraints, i'm not able to go off and learn the PERL language, but these are good references for the future. thx

Report •

#3
May 4, 2010 at 02:24:19
The SORT command in *nix can do just that: sorting lines and treating numbers as numbers, example:

1
2
8
11
12
100

Instead of a normal SORT (based on alfabet):

1
100
11
12
2
8

So, my advice would be, to get a sort.exe from the Net, which is ported from *nix to windows, and make sure it includes this kind of sorting.


Report •

Related Solutions


Ask Question