Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing the data

Status
Not open for further replies.

Coderifous

Programmer
Dec 13, 2001
782
US
Hey all,

I have a C++ prog that parses a specific data file, but am trying to write a perl script to perform the same function. For portability reasons.

Basically, the fscanf() function is used to read the data, and I just need to translate the fscanf() template characters, over to perls unpack(). That's my current guess anyways.

Included are: %c %s %ld %d

I do have "field positions and widths" so that's not an issue.

Anyone know how to translate this from C++ to perl?

Thanks for the help,

--jim
 
hi jim

if you're reading a text file and you know the 'field positions and widths', then why doesn't the 'A' format work for *all* fields in the unpack expression?

jaa

 
I'll give that a shot Justice.

I thought that the %l in fscanf() was more along the longs of reading binary data that would need to be interpreted as such, like a long integer.

But I couldn't really work out the specifics. I'll give your suggestion a shot, and post whether it worked.

I have a sneaking suspicion that my data file is fubar anyways. Customer provided of course.

Thanks bud,

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top