Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Seeking help in File program

Posted on 2003-12-09
5
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 84

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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

718 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