in reply to Re: Parsing/regex question
in thread Parsing/regex question

When the script encounters a "Position has rolled into" line it should skip everything up to the datestamp, and place that datestamp into a $position_rolled_into var

Same goes for the "spot/mark has rolled into" :)

Replies are listed 'Best First'.
Re^3: Parsing/regex question
by ikegami (Patriarch) on Jul 06, 2009 at 19:21 UTC

    should skip everything up to the datestamp

    oops, missed the "---" line. Adding one line of code addresses that:

    my $position_rolled = 0; while (<$fh>) { chomp; if ($position_rolled) { next if !/^... .\d 20\d\d/; $position_rolled = 0; $position_rolled_into = $_; } elsif ($_ eq 'Position has rolled into') { $position_rolled = 1; } ... }
Re^3: Parsing/regex question
by superfrink (Curate) on Jul 06, 2009 at 19:03 UTC
    Then in the while loop you can do something like this:
    ... if (0 < $lines_to_skip) { if ($line =~ /datestamp-regex/) { next LINE; } # we are at the next date stamp line so fall through, etc. } ...
    Also rename $lines_to_skip to something suitable.