http://www.perlmonks.org?node_id=1018699


in reply to Seaching for text in string and comparing to xml, if not found print text

My general technique would be to start by extracting a list of all ALARM_ID strings from the XML file. Because of the size, assuming the XML is fairly predictable, it might be best to do this with a simple regular expression. Then use map to convert that list to a hash where the ALARM_ID strings are the keys and the values are all "1".

Then loop through the text file, line by line. Extract the alarm ID from the line; if it's in the hash described in the previous paragraph, then print "Success\n" as output; otherwise, print the line as output.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: Seaching for text in string and comparing to xml, if not found print text
by helpneeded (Initiate) on Feb 14, 2013 at 10:17 UTC
    Can you give me a short example? I am not too farmiliar with the map function, I have not yet used it.