Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Question about concatenation

by eyepopslikeamosquito (Chancellor)
on Dec 23, 2012 at 20:27 UTC ( #1010120=note: print w/replies, xml ) Need Help??


in reply to Question about concatenation

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010120]
help
Chatterbox?
[choroba]: act.yapc.eu
[robby_dobby]: Thanks, choroba
[LanX]: yes and Egypt (like Turkey and Russia) belongs to two continents
[choroba]: Also Europe and Asia are geographically one continent, the division is political
[robby_dobby]: I always thought everything on the other side of Suez to be Africa. That's an entire continent
[LanX]: Sinai_Peninsula
[robby_dobby]: choroba: If you're talking of Eurasia, it's only true of the erstwhile Constantinople/ Ottoman empire
[LanX]: yes correct, but Sinai is not on the other side
[LanX]: Organizing a YAPC in a tourist ressort is not a bad idea ...
[LanX]: ... and we could swap to our first YAPC Africa the following year when organizing in Hurghada

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2017-04-24 16:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.