1. Yes all Perl subs have a return value. Correct.
2. Again we are into semantics. I modified the data structure that was passed into the sub by reference. So write some code that modifies a "list". What would that be? Some authors say that @xyz is a list and that xyz is an array variable that defines a list. What's wrong with saying that @xyz is a list? Or that xyz in the context of @ is a list? Or that (@xyz >1) is a list in a scalar context? | [reply] |
So write some code that modifies a "list". What would that be?
We're still waiting for you to show it's possible.
Some authors say that @xyz is a list and that xyz is an array variable that defines a list.
So far, I've only seen you, and that's the problem.
What's wrong with saying that @xyz is a list?
It's very confusing. It leads to contradictory statements. If we went by your definition, all of the following statements are true depending on whether you are talking about (foo,bar) or @foo.
- A list can't be modified.
- A list can be modified.
- A list in scalar context evaluates to its last item.
- A list in scalar context evaluates to the number of elements it contains.
- Nested lists are flattened into a single list.
- Nested lists aren't flattened into a single list.
[What's wrong with saying] that xyz in the context of @ is a list?
Now you want to redefine "context" too! What do you have against being understood.
[What's wrong with saying] that (@xyz >1) is a list in a scalar context?
You wouldn't be talking about Perl. In Perl, lists evaluate to their last element in scalar context.
print(scalar( ( 'a', 'b', 'c' ) )); # c
However, @xyz does not.
@xyz = ( 'a', 'b', 'c' );
print(scalar( @xyz )); # 3
| [reply] [d/l] [select] |
@xyz = ( 'a', 'b', 'c' );
print scalar (@xyz); #prints 3
is what I would have expected, the number of things in @xyz.
print(scalar( ( 'a', 'b', 'c' ) )); # c
Is different that I would have expected.
I will have to think more about how this occurs!
But I will say that compared with scalar(@xyz) which happens very often, this is rare albeit interesting.
| [reply] [d/l] [select] |