#! perl -nslw use vars qw[%ids]; use strict; BEGIN{$/="\nchecking";} if ( m[<(NT-Development_\d{10}_FULL)>.*?(media does not exist)?\Z]s ) { $ids{$1} = defined $2 ? 'missing' : 'ok'; } }{ #! terminate implied (perl -n) while loop and start continue block #! process hash here. print "$_ was $ids{$_}" for sort keys %ids;