That's what Taulmarill meant.
Basically: an "empty" array can have any size, but an empty list always has size 0.
UPDATE: that should show it...
DB<1> @a[3..5]=()
DB<2> @b[3..5]=()
DB<3> print scalar @a
6
DB<4> print ( () = @a,@b )
DB<5> @c= @a,@b
DB<6> print scalar @c
6
DB<7> @c=(@a,@b)
DB<8> print scalar @c
12
DB<9> print ( () = (@a,@b) )
DB<10> push @a,@b
DB<11> print scalar @a
12
DB<12> x @a
0 undef
1 undef
2 undef
3 undef
4 undef
5 undef
6 undef
7 undef
8 undef
9 undef
10 undef
11 undef
Line 12 clearly shows, that concatenating two "empty" arrays leads to a larger "empty" array...
Anyway the difference between line 5 and 7 is somehow surprising ...
UPDATE: Aaaaaargh!!! 8)
In line 5, I fell into the scalar comma operator trap again ... it's basically (@c=@a),(@b)
-
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 How to display code and escape characters
are good places to start.
|