in reply to Re: Re: Re: Reference to a single array item in an array of hashes?
in thread Reference to a single array item in an array of hashes?

Teach me not to list enough code. It's actually erroring a little later in the loop. Here's the full loop:

my $i = 0; my @jobTimes = ('') x $numTimes; #initialize array foreach my $job (@jobTimes) { $job = { start => param("JobStart$i"), end => param("JobEnd$i"), }; $job{'start'} =~ s/^0+//; $job{'end'} =~ s/^0+//; $i++; }

It's giving the "Global Symbol "%job" requires explicit package" error on the regexpen.

--Alex
  • Comment on Re: Re: Re: Re: Reference to a single array item in an array of hashes?
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Reference to a single array item in an array of hashes?
by tedrek (Pilgrim) on Apr 05, 2004 at 23:27 UTC

    Ah yes that would explain it. $job is a scalar variable holding a reference to the hash, as such you need to dereference it when accessing a specific field of the hash. Like so $job->{start} =~ s/^0+//;


    HTH
    I tried to swear at perl and it compiled!

      Thanks, that worked. I've only recently had to start using references in my code, so I apprectiate your help.

      --Alex