Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^4: What does my @x= (undef)x7; do?by betterworld (Curate) |
on Nov 09, 2015 at 17:53 UTC ( [id://1147267]=note: print w/replies, xml ) | Need Help?? |
Perl code would treat the two the as the same, but user-written XS code makes assumptions. When I read this, I felt an urge to find Perl code that behaves differently for these arrays :) Turns out that what this API function is doing would require explicit undefs even if the function was written in Perl. This is a subroutine that modifies its input parameters. In Perl you might write it like this:
Here the subroutine "modify" behaves similar to GetVolumeInformation as it modifies the scalars in the array passed to it. So the arrays @a and @b should be identical. However, modify() will replace @a with five times 5, but it cannot write to @b:
Update: Since this seems to depend on the version: I am using Perl 5.20.2 on Debian.
In Section
Seekers of Perl Wisdom
|
|