Solved

Seeking help in File program

Posted on 2003-12-09
5
146 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 63 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 84

Assisted Solution

by:ozo
ozo earned 62 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now