Here's some sample code

---
use strict;

my (%hash, @array, @results);

$hash{'name'}{'sub'} = qw(one two three four);

@array = qw(five six seven eight);

$hash{'name'}{'sub'} = ($hash{'name'}{'sub'}, @array);

print @{$hash{'name'}{'sub'}};
---

This produces an error "Can't use string ("4") as an ARRAY ref while "strict
refs" in use at test.pl line 11."

The Perl Cookbook says this "causes a runtime exception under use strict
because you're dereferencing an undefined reference where autovivification
won't occur" and suggests using...

---
use strict;

my (%hash, @array, @results);

$hash{'name'}{'sub'} = qw(one two three four);

@array = qw(five six seven eight);

$hash{'name'}{'sub'} = ($hash{'name'}{'sub'}, @array);

@results = exists( $hash{'name'}{'sub'} )
                ? @{ $hash{'name'}{'sub'} }
                : ();

print @results;
---


Which I've tried, but it produces the same error. Does anyone have some
advice or a workround (other that removing the use strict pragma if
possible).

I've tried combining the arrays like this

push ($hash{'name'}{'sub'}, @array);

and 

push (@{$hash{'name'}{'sub'}}, @array);

with similar errors.

Thanks

John Edwards
IT Support
Runecraft Leeds

Phone: 0113 2206317
Fax: 0113 2206301
Mobile: 07961 356186



--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to