Re: Update in perlop
[email protected] (Shlomi Fish) Thu, 5 Sep 2013 08:40:19 +0300
| Newsgroups | perl.perlfaq.workers |
|---|---|
| Message-ID | <[email protected]> |
Hi Prateek, On Wed, 4 Sep 2013 12:19:17 +0000 "Balasundaram, Prateek" <[email protected]> wrote: > Hello all, > > In the section: > http://perldoc.perl.org/perlop.html#Auto-increment-and-Auto-decrement > > I believe this line is incorrect: > "undef is always treated as numeric, and in particular is changed to 0 before > incrementing (so that a post-increment of an undef value will return 0 rather > than undef)." > > Upon testing: > $ perl -le '$val=undef;print("Initial Value: $val");$val++;print("Incremented > Value: $val");' > Initial Value: > Incremented Value: 1 > What is meant by that is that if you do: shlomif@telaviv1:~$ perl -le 'use Data::Dumper; $x=undef; my $y = ($x++);print Dumper([$y])' $VAR1 = [ 0 ]; shlomif@telaviv1:~$ Hope it helps. Regards, Shlomi Fish > It seems that the post-increment value of undef will be 1, not 0 as the > documentation states. > > Regards, > Prateek > -- > Prateek Balasundaram > [email protected] > (484)562-1281 > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ List of Text Processing Tools - http://shlom.in/text-proc Electrical Engineering studies. In the Technion. Been there. Done that. Forgot a lot. Remember too much. Please reply to list if it's a mailing list post - http://shlom.in/reply .