Trying to extract information from a XML file using this piece of snippet, I'm not getting the desired output as intended and I know its something within the foreach loop, -> My question how one can use the foreach loop in this case
use strict; use XML::Simple; use Data::Dumper; my %top_in_ou_bi; $top_in_ou_bi{"input"}{name}=add; $top_in_ou_bi{"input"}{name}=clk; $top_in_ou_bi{"input"}{name}=dat_in; $top_in_ou_bi{"output"}{name}=dat_out; $top_in_ou_bi{"bidirection"}{name}=ctrl; foreach my $nam(sort keys %top_in_ou_bi){ foreach my $dat(keys %{$top_in_ou_bi{$nam}}){ print"$nam $dat: $top_in_ou_bi{$nam}{$dat}\n"; } }
output:
bidirection name: ctrl input name: dat_in output name: dat_out
Expected output:
bidirection name: ctrl input name: dat_in input name: clk input name: add output name: dat_out
also using "use strict" warns that barewords are not allowed, how one can surpass this warning!
Thanks!
No comments:
Post a Comment