[thelist] Perl references

Dean Mah dmah at members.evolt.org
Wed Feb 19 09:15:02 CST 2003


Try using $$date[3]++;

$date is a reference to an array.
$$date dereferences the scalar $date.

Dean


On Wed, Feb 19, 2003 at 03:08:19PM -0000, Chris Marsh wrote:

> I have a newbie Perl question that is driving me up the wall. I have the
> following:
>
> for ($i = 0; $i < @week; $i++) {
> 	$week[$i]{DATE} = [ @date ];
> 	&incrementDate(\@date, 1);
> }
>
> sub incrementDate {
> 	my($date, $type) = @_;
> 	$date[3]++;
> 	return;
> }
>
> I want &incrementDate to reference original array @date and
> increment index 3 for each pass of the loop, but I'm getting no
> errors but no incrementing either. I suspect that it's my failure to
> grasp referencing implementation in Perl, but I would appreciate
> *any* help here...



More information about the thelist mailing list