Here is a tool I use to unfold long lines in LDAP outputs.
It also works on mailboxes that have the Received: lines
or Content-*: lines folded.
#!/usr/bin/perl
#syntax: unfold.pl filename > newfilename
if ($ARGV[0]) {
local $/ = '';
open(FILE, "<$ARGV[0]") or die "can't open $ARGV[0]: $!\n";
@records = <FILE>;
close(FILE);
}
foreach $record (@records) {
$record =~ s/\n\s//g;
print "$record\n\n";
}
More comments inserted inline;
> Hi ,
>
> I am stuck with input record separator
>
> I have a file .. say "abc"
>
> ***********************************************
> AAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAA
>
> BBBBBBBBBBBBBBBB
> BBBBBBBBBBBBBBBB
> BBBBBBBBBBBBBBBB
>
> CCCCCCCCCCCCCCCC
> CCCCCCCCCCCCCCCC
>
> ***********************************************
>
> I read the file in @lines.
> open(IN, "abc);
The above line is missing the closing quote on your filename, and
you are letting the OPEN statement "assume" the "<" input character.
> @lines = <IN>;
You are no longer reading in "lines", you are reading in multi-line
records. You should treat (and name) them as such.
>
> Now I want to split the file into three records (three other lists).
>
> @a = ("AAAAAAAAAAAAAAAA\n",
> "AAAAAAAAAAAAAAAA\n",
> "AAAAAAAAAAAAAAAA\n");
>
> @b and @c similarly should contain the other two records.
The second paragraph could be modified to fit your needs
rather simply.
$count = 0;
foreach $record (@records) {
@recordnumber$count = $record;
$count++
}
Now if you want to do something with individual lines, you can
do it before the closing brace or in another loop.
Dan Liston
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]