use strict; use warnings; use XML::Parser; my $p1; $p1 = new XML::Parser( Handlers => { Start => \&handle_start, End => \&handle_end, Proc => \&handle_proc }); my @stack; $p1->parse(\*DATA); if (@stack) { warn "stack not empty\n"; } sub handle_start { my ($parser, $element) = @_; print " " x scalar(@stack), "BEGIN $element\n"; push(@stack, $element); } sub handle_end { my ($parser, $element) = @_; my $top = pop(@stack); print " " x scalar(@stack), "END $element\n"; unless ($element eq $top) { warn "expected $element, found $top\n"; } } sub handle_proc { my ($parser, $target, $data) = @_; if ($target eq 'CLG.MDFO') { handle_start($parser, $target); } elsif ($target eq 'CLG.MDFC') { handle_end($parser, 'CLG.MDFO'); } } __END__
Article 5 Recovery of costs 1. All costs resulting from issuing the accompanying documents pursuant to Article 2(2) shall be borne by the food business operator responsible for the consignment or its representative. 2. All costs related to official measures taken by the competent authorities as regards non-compliant consignments shall be borne by the food business operator responsible for the consignment or its representative.