Aside from the fact that Perl itself uses them, $_, $a, $b and $" aren't special.[1] They are just ordinary package variables.
$/ and $\ are special: They are magical vars. I don't know why they are magical vars.
$1 is special: It's a magical var. It's also implicitly localized.
$ perl -MDevel::Peek -e' for my $sym (qw( _ a " / \ 1 )) { warn "\$$sym\n"; Dump($$sym); warn "\n"; } ' $_ SV = NULL(0x0) at 0x7fffc959c850 REFCNT = 1 FLAGS = () $a SV = NULL(0x0) at 0x7fffc95545e0 REFCNT = 1 FLAGS = () $" SV = PV(0x7fffc9554d40) at 0x7fffc95796f0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x7fffc957e030 " "\0 CUR = 1 LEN = 10 $/ SV = PVMG(0x7fffc95732b0) at 0x7fffc95544f0 REFCNT = 1 FLAGS = (GMG,SMG,POK,pPOK) IV = 0 NV = 0 PV = 0x7fffc9574ba0 "\n"\0 CUR = 1 LEN = 10 MAGIC = 0x7fffc9574b40 MG_VIRTUAL = &PL_vtbl_sv MG_TYPE = PERL_MAGIC_sv(\0) MG_OBJ = 0x7fffc95544d8 MG_LEN = 1 MG_PTR = 0x7fffc9574b80 "/" $\ SV = PVMG(0x7fffc95b9a80) at 0x7fffc95797f8 REFCNT = 1 FLAGS = (GMG,SMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x7fffc957aba0 MG_VIRTUAL = &PL_vtbl_sv MG_TYPE = PERL_MAGIC_sv(\0) MG_OBJ = 0x7fffc95797e0 MG_LEN = 1 MG_PTR = 0x7fffc958fb70 "\\" $1 SV = PVMG(0x7fffc9573a00) at 0x7fffc9584420 REFCNT = 1 FLAGS = (GMG,SMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x7fffc9591e50 MG_VIRTUAL = &PL_vtbl_sv MG_TYPE = PERL_MAGIC_sv(\0) MG_OBJ = 0x7fffc9584408 MG_LEN = 1
Update: Added mention that local $_ is special and that $1 is implicitly localized. Added code.
In reply to Re^6: foreach $1
by ikegami
in thread foreach $1
by choroba
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |