Vynce has asked for the wisdom of the Perl Monks concerning the following question:
So I've no idea why, but assignment to a scalar variable seems to change some lvalues.
To wit, warning the return of a particular sub yields a different warning that assigning that value to a scalar and warning that scalar. I cannot fathom why.
Any ideas?
#!/usr/bin/perl ###=- Unpack Vector Weirdness use strict; sub string { return (reverse (unpack ('b8', $_[0]))) } sub showoff { my $vec = shift; my $str; warn 'vvv'; warn string($vec); warn ($str = string($vec)); warn '^^^'; } for my $pass (0..7) { my $vec = int(rand(200)); showoff $vec; }
thanks,
Vynce
.
update:
yes, i know return (unpack ('B8', $_[0])) does what i want, but my question is why the original doesn't.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unpack Vector Weirdness
by runrig (Abbot) on Oct 10, 2005 at 20:16 UTC | |
by Vynce (Friar) on Oct 10, 2005 at 20:23 UTC |