Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: XML::Simple and arrays

by broquaint (Abbot)
on Mar 07, 2003 at 14:59 UTC ( #241147=note: print w/replies, xml ) Need Help??


in reply to XML::Simple and arrays

sub CI_Exists { my $chk = shift; my @nodes = map $rules->{CI}->{$_}, grep { $_ eq $chk } keys %{ $rules->{CI} }; foreach my $n (@nodes) { print "Chk = $chk\n"; foreach my $rec (keys %{ $n->{recipient} }) { foreach my $alert (@{$n->{recipient}->{$rec}->{alert}}) { ## or whatever suits alert_recipient(@$alert{qw/method dest/}, $rec) } } return 1; } return 0; }
Now just fill in sub alert_recipient or whatever works for you and it should do as you wish.
HTH

_________
broquaint

update (broquaint): code now does the intended thing
update 2 (broquaint): fixed keys %$rules->{CI} (that'll teach me for posting untested code)

Replies are listed 'Best First'.
Re: Re: XML::Simple and arrays
by J9 (Beadle) on Mar 07, 2003 at 15:13 UTC
    Thank you,

    However when I try the above code I get this:
    Type of arg 1 to keys must be hash (not hash element)
    What does that mean?

    Oh and it's on the grep { $_ eq $chk } keys %$rules->{CI}; line

    Thanks for the help.

      That should be grep { $_ eq $chk } keys %{ $rules->{CI} };, because without the braces, the % deferences the $rules hashref and not the $rules->{CI} hashref.

      See References quick reference for more illumination. HTH!

      If not P, what? Q maybe?
      "Sidney Morgenbesser"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://241147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2023-12-01 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?