Subject: | Time::HiRes::stat breaks list subscripting |
Not completely sure if this is a bug in Time::HiRes (as opposed to perl
itself).
$ perl -MTime::HiRes -e 'print +(stat("foo"))[8], "\n"' # V1
1322915623
$ perl -MTime::HiRes=stat -e 'print +(stat("foo"))[8], "\n"' # V2
8
$ perl -MTime::HiRes=stat -e '@a = stat("foo"); print $a[8], "\n"' # V3
1322915623
The 8 being returned by V2 isn't right. In fact, you can put any
sillyness you want in the list subscript:
$ perl -MTime::HiRes=stat -e 'print +(stat("foo"))[JAPH], "\n"'
JAPH
It also isn't just a general bug with function calls, because this works:
$ perl -e 'sub bar() { return qw(a b c d e f g h i j) }; print
+(bar)[8], "\n"'
i
See also me asking this on Stack Overflow:
http://stackoverflow.com/q/8367789/27727
This has been tested on:
- Debian Perl 5.14.2-5 / 1.972101
- Debian Perl 5.10.1-17squeeze2 / 1.9719
- Gentoo Perl 5.14.2 (by cjm http://stackoverflow.com/a/8368432/27727)
- Gentoo Perl 5.8.9 (by cjm http://stackoverflow.com/a/8368432/27727)
- Gentoo Perl 5.10.0 (by cjm http://stackoverflow.com/a/8368432/27727)