in reply to Re: XML::Simple help
in thread XML::Simple help
A couple of comments:
- in a handler you can use $_ as an alias for $_[1]
- unless speed is a big concern, you should really use the proper methods to access attributes, and write $_->att( 'code') instead of $_->{'att'}->{'code'} and $_->set_att( code => $value) instead of $_->{'att'}->{'code'}= $value: there is no guaranty that the attributes will always be in a simple hash, nor than the methods only read or assign to the att hash (they do at the moment, but is very likely to change).
With those changes, the handler code becomes:
sub{ $hash->{$_->att('code')}=$_->att->( 'name'); }
|
---|
In Section
Seekers of Perl Wisdom