Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Seeking help in File program

Posted on 2003-12-09
5
Medium Priority
?
173 Views
Last Modified: 2010-03-04
Hi,

There is a file which contains a few lines. Each line has a hexadecimal number eg: abcdef12
Create a new file by swapping the data in bytes as: 12efcdab
How do I do this. Are there any inbuilt functions to implement this

Thanks
Kunal
0
Comment
Question by:Kunal_Sathe
  • 3
5 Comments
 
LVL 20

Accepted Solution

by:
jmcg earned 252 total points
ID: 9908303
If this is a homework problem, please show us some of your work and we may be able to help you.

If it's not a homework problem, please give some more context for why you want to do this. There may be a better approach before the data is written to the file in the wrong order.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9909981
One way to effect the byte reordering is:

s/(..)(..)(..)(..)/$4$3$2$1/;
0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 248 total points
ID: 9910391
Another way is to use pack/unpack and reverse
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10218563
Nothing has happened on this question in more than 7 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between jmcg and ozo.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question