Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

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

The difference is because the range operator behaves differently in list context to scalar context. BTW, so do arrays. As indicated in the test program below, the array returns the number of elements in scalar context, while the flip flop operator returns false (represented as undef), which prints as an empty string. Running:

use strict; use warnings; print "Counting up: " . (1..6) . "\n"; # scalar context (undef) print "Counting up: " , (1..6) , "\n"; # list context print "Counting up: @{[1..6]}\n"; # list context, space bet +ween each element my @one_to_six = 1..6; print "Counting up: " . @one_to_six . "\n"; # scalar context (no. of +elts) print "Counting up: " , @one_to_six , "\n"; # list context
produces:
Use of uninitialized value $. in range (or flip) at cnt.pl line 4. Counting up: Counting up: 123456 Counting up: 1 2 3 4 5 6 Counting up: 6 Counting up: 123456


In reply to Re: Question about concatenation by eyepopslikeamosquito
in thread Question about concatenation by chiggly007

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (10)
    As of 2014-09-02 15:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (25 votes), past polls