Hi Guru's.. I am trying to do simple text processing script. Currently I am using this script. After matching the pattern, it writes the next line to the output file. It works fine and it give me the output, but I still need to process the output in excel to arrange the data's.

Code

#! /usr/bin/perl -w open INF, 'infile.txt' or die "Could not open file"; open OUT, '>outfile.txt' or die "Could not write to the file";

Re: [bha148] Match pattern and print the next line to the file
[In reply to]

Can't Post

Glad it is working for you.

Maybe I can explain some information on what the $format variable I am using for the unpack function.

Code

my $format = 'x18A15A15A14';

This tells unpack how to parse the text you want.

x18 - skip first 18 characters (which are 18 spaces that precede the first field you want to capture). A15 - capture the next 15 characters and spaces A15 - same thing A14 - capture next 14 spaces or characters.

So that explains about the $format variable.

One behavior when unpacking text with 'A' is that it will trim off any trailing space.