How to parse a fixed length record

B

byrapaneni

Hi;
I am a new beeeee to perl. Please help me with the following.
I have a 80 position fixed recrod that I need to parse by column for
reporting.

Example:
0322095000101572000020600000200050630050630000000000000000000001108961000000016430023sf+FM+12691*206+FM110

Field1: 1-4
Field2: 5-8
Field3: 9-14
Field4:15-31
Field5:32-34
Field6:35-40
Field7:41-54
Field8:55-80

Can somebody please help me to parse the above fixed length record?

Thanks in advance.

SB
 
J

John W. Krahn

I am a new beeeee to perl. Please help me with the following.
I have a 80 position fixed recrod that I need to parse by column for
reporting.

Example:
0322095000101572000020600000200050630050630000000000000000000001108961000000016430023sf+FM+12691*206+FM110

Field1: 1-4
Field2: 5-8
Field3: 9-14
Field4:15-31
Field5:32-34
Field6:35-40
Field7:41-54
Field8:55-80

Can somebody please help me to parse the above fixed length record?

my @fields = unpack 'a4 a4 a6 a17 a3 a6 a14 a6', $string;

perldoc -f pack
perldoc -f unpack
perldoc perlpacktut


John
 
I

Ian Wilson

perlUSER said:
perldoc - f on the functions doesn't work on my server. Any ideas why?

Possibly because there shouldn't be a space between the "-" and the "f"?

In general its best to cut & paste your command + error message into
your posting. "doesn't work" isn't very useful as a description of a
message.

Depending on platform/package manager/repository you may need to install
the perl documentation separately. There was a thread on this recently,
which google should be able to find for you.
 
P

perlUSER

This is the command and the system response.

***************************************************************

$ perldoc -f pack
No documentation found for "perlfunc".
$

***************************************************************

Thank you for the suggestion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top