in reply to match tags
A simple approach.
use strict; use warnings; my $found = ''; while(<DATA>){ chomp; if($_=~ /^\.\.AU:$/) { $found = 'AU'; next; } if($found eq 'AU'){ print "\n".$_; } if($_=~ /^\.\.BD:$/) { $found = 'BD'; next; } if($found eq 'BD'){ print ','.$_; } $found = ''; }
UPDATE: Could have been shorter ;)
my $tag; while(<DATA>){ chomp; if(/([A-Z]{2}):$/){ $tag = $1; next; } if($tag eq 'AU'){ print "\n".$_; } if($tag eq 'BD'){ print ','.$_; } }
|
|---|