in reply to Can't use string ("250") as an ARRAY ref while "strict

Hi. You should use diagnostics to get a better explanation of warnings/errors (or you could just read perldoc perldiag).

Dumper outputs

$VAR1 = { 'name' => 'Coffee' };
, which is obviously not what you expected $category to be. This is because my $cat = (<DATA>); read only 1 line from DATA (perldoc -f readline). You should try my $cat = join '', <DATA>;.

update: After making the above change I get Can't use string ("250") as an ARRAY ref while "strict refs" in use at foo.pl line 34. and line 34 is foreach my $content (@{$conditionning->{'content'}}).
Basically, $category->{'subcategory'}[0]{'product'}[0]{'conditionning'}[0]{'content'} is '250' (just like <conditionning unit="gr">250</conditionning>) and not an array.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: Can't use string as an ARRAY
by Maxim (Sexton) on Oct 02, 2004 at 11:41 UTC
    Thanks to help me. I understand now. I would like if you can give me a full example please. I will try what you just gave me :).
    Thank you very much
Re^2: Can't use string as an ARRAY
by Maxim (Sexton) on Oct 03, 2004 at 01:26 UTC
    I understand you wrote. What I want is replace "250" by "500". I don't know how to change it.
    Thanks
      I don't think you do. This is one way
      $category->{'subcategory'}[0]{'product'}[0]{'conditionning'}[0]{'conte +nt'} = 500;

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

        I put it the wrong way. But Thank you so much.