in reply to block extraction

Be encouraged! This is a great case to learn how wonderful Perl is. In addition to the other suggestions, look up $/, which will allow you to break your file into records very easily.

Replies are listed 'Best First'.
Re^2: block extraction
by zzgulu (Novice) on Feb 04, 2009 at 14:16 UTC
    Thank you for the hints. I started like below but I guess I'm way off! Do you suggest to go another direction? Thank you for the help

    open IN, "." || "die, can't open";
    undef($/);
    $string=<IN>;
    $string=~m/(^Processing\s\d+\.tx\.\d+:)(.*?)(^Phrase:)(.*?)(Meta Mapping)(.*?)(\n)/g;
    print "$2\t$4\t$6";
    exit;

      Here's a simple example to open the file and print out the records. When you understand this, you can begin to manipulate the records before printing.

      use strict; use warnings; my $file = "t.txt"; $/="\n\n"; open IN, "<", $file or die "Unable to open $file: $!"; while(<IN>){ print "=======\n", $_, "=======\n\n"; } close IN;
        Thank you hbm