open( XML, "source_of_xml.data" ) or die "I died 'cuz $!"; { local $/ = "\n"; my %item; while () { # read one whole ... into $_ for my $tag (qw/name working uptime downtime/) { ($item{$tag}) = m{<$tag>(.*?)}s; # (leave off "s", # if tags are always fully contained on one line) } # now, do what you want with %item... } }