if ( /]+)>/ ) { my $attribString = $1; # The challenge is to split the line properly into key/val # pairs; first, let's get rid of boundary stuff that might # get in the way: $attribString =~ s{^\s+}{}; # initial whitespace $attribString =~ s{[/\s]+$}{}; # final whitespace and/or "/" # now split into key,val pairs, assuming that " = " falls # between attrib name and attrib value, while the boundary # between a value and the next attrib name is whitespace # preceded by double-quote and followed by alphanumeric: my %attribHash = split( /\s+=\s+|(?<=\w\")\s+(?=\w)/, $attribString ); # That's it; now work with the keys and values of that hash... #### die "Bad xml tag:\n$_\n" if ( grep( /\"/, keys %attribHash );