I have a pointer to an array and either need to change the code considerably to make this work, or just figure out what the equivilent of the statement below is…
ptr = array;
*ptr++ = value;
So far I have most of it
$ptr = \@array;
$$ptr = $value;
but this doesn’t increment the pointer. What do I do?
There are no pointers in Perl. What you have is:
$ary_refis now a reference to@array. You cannot dereference$ary_refto get a scalar.You can, however, iterate through the elements of
@arrayin a variety of ways. For example, if you want, you can do:By the way, there is no reason you can’t write
in C. In Perl, it might become:
or,
or,
etc. You should explain what the overall goal is rather than asking about a specific statement in C.