HERE're my attempts at getting to know and understand:
#!/usr/bin/perl
use strict;
use warnings;
use XML::Twig;
# perl test_thandi CCC '@n=AAA'
# perl test_thandi CCC '@n="AAA" or @set="y"'
my( $ac_n_value, $ai_att_cond)= @ARGV;
XML::Twig->new( TwigHandlers =>
{
# qq{AC[\@n="$ac_n_value"]/AI[$ai_att_cond]} => \&print_ai_data },
# qq{AC[\@n="$ac_n_value"]/AI[$ai_att_cond]/ID[\@n=$id_att_cond]} => \&print_id_data },
# ID => \&id_print , #list all IDs desc
# AI => \&ai_print ,
qq{AC} => \&ac_print, #list all ACs
qq{AC/AI} => \&ai_print, #list all AIs
},
pretty_print => 'indented',
# keep_atts_order => 1,
# do_not_chain_handlers => 1
) ->parsefile( "custs.xml");
sub ac_print
{
my( $t, $ac)= @_;
my $Desc = $ac->first_child('Desc')->text;
print "AC DESC: $Desc\n";
print "=======================================\n";
}
sub ai_print
{
my( $t, $ai)= @_;
my $Desc = $ai->first_child('Desc')->text;
print "AI DESC: $Desc\n";
print "----------------------------------\n";
}
sub id_print
{
my( $t, $id)= @_;
my $Desc = $id->first_child('Desc')->text;
my $What = $id->first_child('What')->text;
my $AR = $id->first_child('AR')->text;
print "--> DESC: $Desc\n";
print "What: $What\n";
print "AR: $AR\n";
}