Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Print a previous to previous of a matching line

by McA (Priest)
on Oct 08, 2013 at 09:46 UTC ( #1057396=note: print w/replies, xml ) Need Help??

in reply to Print a previous to previous of a matching line


in this case I would take the following approach:

#!/usr/bin/env perl use strict; use warnings; use 5.010; # read first line assuming it is a kind of block seperator my $bsep = <>; $/ = $bsep; while(defined(my $block = <>)) { chomp $block; my @records = split /\n/, $block; next if @records < 3; # malformed block foreach my $record (@records) { say $record; } say "========================"; }

Now you can find and operate on every block how you like.

Best regards

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1057396]
[LanX]: quick survey ... Module::Build, ExtUtils:: ModuleMaker or Module::Starter ?
[Your Mother]: Module::Install
[Your Mother]: :P
[LanX]: Moma knows best! ;-)
[Your Mother]: I am quite aware that Module::Build is MUCH more in favor with many monks but I had trouble with it every time I tried to use it and trouble with CPAN stuff that used it too.
[Your Mother]: Take my advice with a grain of salt. I haven't done a new CPAN release in years at this point.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2017-08-18 17:35 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (306 votes). Check out past polls.