#!/usr/bin/perl use strict; use warnings; my $index = 0; my @nsi = (q~13523~); my %xmlstring = ( QueryCId => qr/]*>\s*(\d+)\s*<\/nC[o]?ntr[a]?ctID>/s, ); print "\n1 reg: ", $nsi[$index] =~ /$xmlstring{'QueryCId'}/; $nsi[$index] =~ /$xmlstring{'QueryCId'}/ ? print "\nMATCH" : print "\nNO MATCH"; my $cid = $nsi[$index] =~ /$xmlstring{'QueryCId'}/ ? '' : 'I HATE YOU'; print "\nCID should be empty: ", $cid;