Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-05-23 20:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?