Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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]
[james28909]: ok maybe i need to ask this question in sopw and not CB but here goes
[james28909]: i am manually parsing html, and am trying to wrap my head around keeping up with tag counts
[james28909]: i can extract a certain tree manually by regexing the html file for a starting anchor, then i send the position of the match to a sub and then seek to that position in the file and keep up with div tags (for now)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-04-25 03:50 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (448 votes). Check out past polls.