my ($file) = $string =~ /([^<]+)/; my ($line) = $string =~ /([^<]+)/; my ($type) = $string =~ /([^<]+)/; my ($codee) = $string =~ /([^<]+)/; my ($desc) = $string =~ /([^<]+)/; #### my %info; # a better name should be picked foreach ( qw/ file line type codee desc / ) { my ($info{$_}) = $string =~ /<\Q$_\E>([^<]+)/; }