Actually id say that that regex is not quite right. First of all this comes down to the defintion of a bareword, which isnt well defined from what ive read. But if we must discuss a regex for this purpose I would say it would be more like the following, but even then its not _entirely_ clear (the issue of v strings rears its head as well as a few other issues)
/^\s*([-A-Z_a-z][A-Z_a-z0-9]*|\d+)\s*/
(Im debating the \s* bit. Ive put it in becuase of Juerds comment below, but on reflection I dont actually think its necessary as the tokenizer would be remove the whitespace the surrounds the token preceeding the => digraph before the parser even saw the digraph.)

To be honest IMO there isnt an exact regex. The rules of the tokenizer are not representable by a regex as far as I know. (I could be wrong, it happens a lot. :-)

Some bizarre examples:

use strict; use warnings; local $\="\n"; local $,="\t"; print Zaxo => 'Juerd'; print Zax0 => Ju3rd => 'Foo'; print -abcde=>'foo'; print v9.100.101.109.101.114.112.104.113.9 => v65; print 0 => 'foo'; print v48.65 => 'A0'; print 0x00 => 'foo'; #prints 0 not 0x00 # print 1a2b => 'foo'; #doesnt work, cant have alphas when the key sta +rts with a digit (0x excepted) # print 1a-2b => 'foo'; #doesnt do what you might think, evals to 0
Anyway, if you are interested in this , there is currently a discussion on p5p about the behaviour of => (started by Abigail-II) called
[perl #16010] v-strings left of a => don't get quoted.
It seems the issues of => and v strings are quite convoluted. :-)

Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)


In reply to Re: Re: Why dosen't => quote barewords with ::? by demerphq
in thread Why dosen't => quote barewords with ::? by MrNobo1024

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.