in reply to Re: Match on line, read backwards to opening xml tag then forward to closing tag
in thread Match on line, read backwards to opening xml tag then forward to closing tag

my ($flag,@lines); my $d='Dataentry'; sub process { push (@lines,"$_[0]\n"); $flag ||= $_[0]=~ m@>bbbbbb<@s; @l ='' if ($_[0]=~m@</$d>@s); if (($_[0]=~ m@<$d>@s)&&($flag)) { pop @lines; say "<$d>"; print reverse @lines; say "</$d>"; @lines = ''; $flag = 0; } } process $_ for reverse split '\n';
  • Comment on Re^2: Match on line, read backwards to opening xml tag then forward to closing tag
  • Download Code