Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to parse a fixed length record

Reply
Thread Tools

How to parse a fixed length record

 
 
byrapaneni@gmail.com
Guest
Posts: n/a
 
      07-30-2005
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:
03220950001015720000206000002000506300506300000000 00000000000001108961000000016430023sf+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

 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      07-30-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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:
> 03220950001015720000206000002000506300506300000000 00000000000001108961000000016430023sf+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
--
use Perl;
program
fulfillment
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      07-30-2005
(E-Mail Removed) wrote:
> 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.


Check out

perldoc -f substr

> Thanks in advance.


You're welcome.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
perlUSER
Guest
Posts: n/a
 
      07-30-2005
Thank you very much.

 
Reply With Quote
 
perlUSER
Guest
Posts: n/a
 
      08-01-2005
perldoc - f on the functions doesn't work on my server. Any ideas why?

 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      08-01-2005
perlUSER wrote:
> 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.
 
Reply With Quote
 
Fabian Pilkowski
Guest
Posts: n/a
 
      08-01-2005
* perlUSER schrieb:

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

^^^
Remove the space between "-" and "f". Try:

perldoc -f substr

Alternatively you could read all perldoc pages online, e.g. at

http://perldoc.perl.org/functions/substr.html

regards,
fabian
 
Reply With Quote
 
perlUSER
Guest
Posts: n/a
 
      08-01-2005
This is the command and the system response.

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

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

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

>> 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.


Thank you for the suggestion

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FAQ 5.8 How can I manipulate fixed-record-length files? PerlFAQ Server Perl Misc 0 04-16-2011 10:00 AM
Create a record with fixed length matou Perl Misc 2 11-19-2008 01:59 AM
Reading Fixed Length Record File cksanjose Java 3 10-28-2006 04:25 PM
Free Fixed-Width/Fixed-Pitch fonts? johnp HTML 4 05-23-2005 06:14 AM



Advertisments