#!/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, ); my $cid; my %xmlstring = ( QueryCId => qr/]*>\s*(\d+)\s*<\/nC[o]?ntr[a]?ctID>/s, ); print "\nreg: ", $nsi[$index] =~ /$xmlstring{'QueryCId'}/; $nsi[$index] =~ /$xmlstring{'QueryCId'}/ ? print "\nMATCH" : print "\nNO MATCH"; $nsi[$index] =~ /$xmlstring{'QueryCId'}/ ? $cid = '' : $cid = 'I HATE YOU'; print "\nCID should be empty: ", $cid;