On 4 Dec 2006 at 8:47, Tom Phoenix wrote:

> On 12/4/06, Beginner <[EMAIL PROTECTED]> wrote:
> 
> >         print "found $ref->{'order_number'}\n";
> 
> > I get "found HASH(0xacacfe8)".
> 
> That's a reference to a hash. It sounds as if you might want to ask
> the question "Is that hash empty or not?", which the keys() function
> can answer:
> 
>     if (keys %{ $ref->{'order_number'} }) {
>       print "There's something in the order number hash.\n";
>     } else {
>       print "Hash is empty.\n";
>     }
> 
> If you use keys() in a list context, you'll get a list of the keys of
> the hash. Hope this helps!

Yes that worked fine. Thanx. Within the same xml file structure I 
also have 

          'address' => {
                       'line' => [
                                 {
                                   'line' => 'STARLING ROOFING'
                                 },
                                 {
                                   'line' => '338 EUSTON ROAD'
                                 },
                                 {
                                   'line' => 'DUBLIN'
                                 },
                                 {
                                   'line' => {}
                                 },
                                 {
                                   'line' => {}
                                 },
                                 {
                                   'line' => {}
                                 },
                                 {
                                   'line' => 'DB1 3BH'
                                 }
                               ]
                     },

Using that principle I thought I could do

if (keys(%{$ref->{'address'}{line}[$j]->{line}}) ) {
        print "Found ", $ref->{'address'}{line}[$j]->{line}, "\n";

But I am getting an error:
Can't use string ("STARLING ROOFING") as a HASH ref while "strict 
refs" in use.

Am I accessing the values incorrectly?

Thanx Again.
Dp.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to