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

  1. local $_ is special, though.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.