note
ikegami
<p><c>-bareword</c> is the same as <c>"-bareword"</c>.
<c>
>perl -e "use Devel::Peek; $x="-bareword"; Dump($x); $x=-bareword; Dump($x)"
SV = PV(0x226150) at 0x226000
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x1835404 "-bareword"\0
CUR = 9
LEN = 12
SV = PV(0x226150) at 0x226000
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x1835404 "-bareword"\0
CUR = 9
LEN = 12
</c>
<p>There's nothing special about <c>-Infinity</c>.
<c>
>perl -e "use Devel::Peek; $x="-Infinity"; Dump($x); $x=-Infinity; Dump($x)"
SV = PV(0x226150) at 0x226000
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x1835404 "-Infinity"\0
CUR = 9
LEN = 12
SV = PV(0x226150) at 0x226000
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x1835404 "-Infinity"\0
CUR = 9
LEN = 12
</c>
<p>A string that doesn't look like a number is the same as <c>0</c> in a numerical context (although it will give a warning if warnings enabled).
<p>The index expression of an array is evaluated in a numerical context.
<p>So they both print 5.
<c>
>perl -e"@a = (5 .. 10); print qq{$a['Infinity']\n$a[-Infinity]\n};"
5
5
</c>
<p><b>Update</b>: There appears to be a bug. <c>'Infinity'</c> and <c>-Infinity</c> don't trigger the warning.
657332
657332