S
s · reservoir
The subroutine is this:
sub mess_with_bits(\$$;$) : lvalue {
do {
eval {
${$_[0]} = ''
};
cluck $@ if $@;
} if (!defined ${$_[0]});
my $r = shift;
my $p = shift;
if (@_) {
my $o = vec($$r => $p, 1);
vec($$r => $p, 1) = shift;
return $o;
}
vec($$r => $p, 1);
}
But when I do this:
mess_with_bits($str, 17) = 1;
print mess_with_bits($str, 2), "\n"'
it prints 1.
sub mess_with_bits(\$$;$) : lvalue {
do {
eval {
${$_[0]} = ''
};
cluck $@ if $@;
} if (!defined ${$_[0]});
my $r = shift;
my $p = shift;
if (@_) {
my $o = vec($$r => $p, 1);
vec($$r => $p, 1) = shift;
return $o;
}
vec($$r => $p, 1);
}
But when I do this:
mess_with_bits($str, 17) = 1;
print mess_with_bits($str, 2), "\n"'
it prints 1.