#!/usr/bin/env perl use strict; use warnings; my @files = @ARGV || glob "*.xml" or die "No files specified!"; my %xmlstring = ( Hzbprtype => qr/]*>\s*52\s*<\/kBPrType>/s, ); for my $file ( @files ) { my @cont = do { local(*ARGV, $_, $/); @ARGV = $file; $/ = ""; <>; } if ( -r $file ); for ( @cont ) { if ( /$xmlstring{'Hzbprtype'}/ ) { print "\n$file\ncall #1"; } if ( /$xmlstring{'Hzbprtype'}/ ) { print "\n$file\ncall #2"; } if ( /$xmlstring{'Hzbprtype'}/ ) { print "\n$file\ncall #3"; } if ( /$xmlstring{'Hzbprtype'}/ ) { print "\n$file\ncall #4"; } if ( /$xmlstring{'Hzbprtype'}/ ) { print "\n$file\ncall #5"; } } }