Inga_dusha
asked on
Files ,working with numers in Hex-Dec
Hi ,plese help me to solve the problem:
I have a file with content
Adress1 Adress2 ColumnA ColumnB
----------- ------------ -------------- -------------
010FAC3 2345ABC Text1 Text2
010AAB3 1345ABC Text3 Text4
010BA13 1234567 Text5 Text6
.
.
.
Adress1 and Adress2 are some memory adreseses in HEX
I need a script in perl that read this file and add to the file column (Adress2-Adress1)in decimal and if it's not difficult sorted by this new column
Output file should be :
Adress1 Adress2 NewColumn(Adress2-Adress1 in decimal) ColumnA ColumnB
010BA13 1234567 17992532 Text5 Text6
010AAB3 1345ABC 19116041 Text3 Text4
010FAC3 2345ABC 35872761 Text1 Text2
Please can somebody help me in solving this problem
Thanks,
Inga
I have a file with content
Adress1 Adress2 ColumnA ColumnB
----------- ------------ -------------- -------------
010FAC3 2345ABC Text1 Text2
010AAB3 1345ABC Text3 Text4
010BA13 1234567 Text5 Text6
.
.
.
Adress1 and Adress2 are some memory adreseses in HEX
I need a script in perl that read this file and add to the file column (Adress2-Adress1)in decimal and if it's not difficult sorted by this new column
Output file should be :
Adress1 Adress2 NewColumn(Adress2-Adress1 in decimal) ColumnA ColumnB
010BA13 1234567 17992532 Text5 Text6
010AAB3 1345ABC 19116041 Text3 Text4
010FAC3 2345ABC 35872761 Text1 Text2
Please can somebody help me in solving this problem
Thanks,
Inga
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ozo's suggestion reads STDIN
ASKER
It's should be something like this or what ?
open(file1, "<file.txt") || die("Could not open result file");
while( $record = <file1> ){
next unless /^[0-9a-f]+\s+[0-9a-f]+/i;
push @x,[split];
}
Thanks for help