in reply to Re^2: block extraction
in thread block extraction

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;

Replies are listed 'Best First'.
Re^4: block extraction
by zzgulu (Novice) on Feb 04, 2009 at 18:54 UTC
    Thank you hbm

      Note hbm's use of strictures - always use strictures (use strict; use warnings;).

      Also notice that hbm used the three parameter version of open and checked the result of the open by using very low precedence or rather than high precedence || which checks to see if the last parameter is true or not (not what you are wanting I suspect).

      There are a couple of changes I'd make though. Use local to localize the effect of changing special variables ($/ in this case) and use a lexical file handle:

      ... local $/="\n\n"; open my $inFile, "<", $file or die "Unable to open $file: $!"; while(<$inFile>){ ...

      Perl's payment curve coincides with its learning curve.