The , aka the comma operator can be used to separate a list like @list = (1,2,3,4); or you can use it to separate expressions like this:

$var = "Hello", $var .= " World!" , print $var;

As you can see the , is acting like a ; Technically what happens is that Perl evaluates the expression on the left hand side and then throws the (return) value away. It then evaluates the expression on the RHS and returns this value. As we care more about the result of evaluating the expression not the return value this is not an issue. See perlman:perlop for more details. The => or "fat comma" operator is just a synonym for ,

As to the barewords these are an interesting feature. Somtimes known as the poetry optimisation. Run this code and see perlman:lib:strict in the subs section.

use diagnostics; bareword;

We use perl functions at the begining of lines all the time - consider print, open, close ..... Just because a function does something and returns a value does not mean you have to use it or even look at it.

use strict; use warnings; sub myfunc { return "Something" } myfunc; print myfunc;
You will notice that the calls to the sub myfunc look like barewords but because Perl looks to see if a bareword is a known function this works, and even passes strict and warnings. This would fail if myfunc was not defined before we called it - either in full or as a prototype - because if Perl has not seen a sub definition for myfunc it is a bareword and strict she no like barewords.

As to why specific things compile you can learn a lot if you add use strict; use warnings; and use diagnostics; to a poem. Look after the readmore to see Perls objections to my poem if you add use strict!

Bareword "LILO" not allowed while "strict subs" in use at index.pl lin +e 7. Global symbol "$finished" requires explicit package name at index.pl l +ine 26. Bareword "booting" not allowed while "strict subs" in use at index.pl +line 6. Bareword "something" not allowed while "strict subs" in use at index.p +l line 11. Bareword "hangs" not allowed while "strict subs" in use at index.pl li +ne 11. Bareword "options" not allowed while "strict subs" in use at index.pl +line 15. Bareword "none" not allowed while "strict subs" in use at index.pl lin +e 16. Bareword "again" not allowed while "strict subs" in use at index.pl li +ne 17. Bareword "booting" not allowed while "strict subs" in use at index.pl +line 19. Bareword "LILO" not allowed while "strict subs" in use at index.pl lin +e 20. Bareword "Linux" not allowed while "strict subs" in use at index.pl li +ne 21. Bareword "something" not allowed while "strict subs" in use at index.p +l line 24. Bareword "Linus" not allowed while "strict subs" in use at index.pl li +ne 24. Bareword "booting" not allowed while "strict subs" in use at index.pl +line 28. Bareword "LILO" not allowed while "strict subs" in use at index.pl lin +e 29. Bareword "something" not allowed while "strict subs" in use at index.p +l line 33. Bareword "hangs" not allowed while "strict subs" in use at index.pl li +ne 33. Bareword "again" not allowed while "strict subs" in use at index.pl li +ne 33. Bareword "options" not allowed while "strict subs" in use at index.pl +line 37. Bareword "again" not allowed while "strict subs" in use at index.pl li +ne 37. Bareword "again" not allowed while "strict subs" in use at index.pl li +ne 38. Bareword "again" not allowed while "strict subs" in use at index.pl li +ne 39. Bareword "Bill" not allowed while "strict subs" in use at index.pl lin +e 41. Bareword "Bill" not allowed while "strict subs" in use at index.pl lin +e 42. Bareword "Bill" not allowed while "strict subs" in use at index.pl lin +e 43. Bareword "make" not allowed while "strict subs" in use at index.pl lin +e 45. Bareword "plan" not allowed while "strict subs" in use at index.pl lin +e 45. Execution of mylife.pl aborted due to compilation errors.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Re: My Life by tachyon
in thread My Life by tachyon

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.