First of all, in Perl there are no "string constants" (whatever that is). Perl doesn't require you to quote your strings, but it's considered good form to do. In fact, if you don't quote, -w will issue a warning (usually, it's Perl so there are exceptions), and with "use strict", you will get a compile time error. (Note that you can only use unquoted strings if the strings look like valid identifiers, possibly preceeded by a minus sign).

However, there are two exceptions. If a string looks like a valid identifier it doesn't have to be quoted if it's either used as a hash key, or on the left side of a fat arrow (=>). This is done to help the programmer; there is little room for mistakes here, when used as a hash key, you usually mean to use the string, not to call a possible function with that name (called without arguments). If you do want to call such a function, you can always preceed it with a +, or a put () behind it.

the qw() function turns whitespace-delimited unquoted string literals into a list of quoted string literals, if I'm not mistaken.
You are very mistaken. You are confusing syntax with semantics. qw returns a list of strings. Strings are values. The different forms of string literals (bareword, single quoted, double quoted, here document) are syntax constructs, but once compiled, there's no difference.

Abigail


In reply to Re: quoting style for lists by Abigail-II
in thread quoting style for lists by erikprice

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.