Kurt Faymon wrote: > Given the Input of: > > <H1>whatever..... > <H2>whatever..... > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > <H2>whatever..... > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > <H4>whatever..... > <p>whatever..... > <p> > > How can I read in the records bases on 'blocks starting with <H,, that is > grouped as follows: > > Record1: > <H1>whatever..... > <H2>whatever..... > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > > Record2: > <H2>whatever..... > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > > Record3: > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > > Record 4: > <H3>whatever..... > <H4>whatever..... > <p>whatever..... > > Record 5: > <H4>whatever..... > <p>whatever..... > <p> > > Setting $/ to something? Use the Split function? having tried variations > of these and/or postive and negative lookahead's have left me obviously > missing something? Any ideas? > > Thanks - kf
read until you counter a line starting with <p> which marks the end of the previous record: #!/usr/bin/perl -w use strict; my $end_of_record = 0; my @records; open(LINES,'foo.txt') || die $!; while(<LINES>){ if($end_of_record){ #-- a record is holding in @records #-- do whatever you need to do $end_of_record = 0; @records = (); } push(@records,$_); $end_of_record = 1 if(/^<p>/); } close(LINES); __END__ didn't actually test the above but it should work. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]