Re: data become zero after shift



yong wrote:
> This is a part of a program which used to do base64 encode.

Hmmm. I wonder if there's a module for this on CPAN?

> }else
> {
> my $first_unpack=unpack("C",$firstbyte);
> print "\nfirst unpack is: ";
> print $first_unpack; # I get correct data here
> print "\n";
> }

The variable $first_unpack is lexically scoped (by 'my') to this block.
This becomes a whole new variable, and has no relationship to the
variable of the same name which you declared a few lines earlier. It
ceases to exist outside this block, and you're back to using the
previously defined variable of the same name, which is (still) undef.

.