Solved

Seeking help in File program

Posted on 2003-12-09
5
154 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pattern matching in perl 2 111
Perl output collect 7 69
Perl Scripting from a shell script with if and for 4 87
Perl script to process a .csv file 18 62
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 …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…

749 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