>Then please explain why scalar(return (1,2,3)) doesn't do what at first
>glance it seems it should.

Because X(Y) != Y(X).  You should have written "return scalar" if you 
wanted to return a scalar.

>And for the life of me I can't see how
>       $x=(1,2, (3,4,fn,6) )   
>fn ends up in scalar context.

Technically, it's in void context, which I suppose you might
reasonably lump in as scalar context.  It's in void context because
you aren't going to be using any possible return value.  If you
want to say its scalar in the sense of !wantarray, then you can
readily see why: the assignment is a scalar one, and thus confers
scalar context to the right-hand expression.

>I'm able to accept that $x=(...) has the inside of the parenthesis in
>a scalar context . But with $x=(...., (....), ...), why shouldn't the
>nested set of parenthesis make its insides into a list.

Because that's not what parentheses do, of course: they don't make
nested lists.  There *are* no nested lists: you cannot have a
component of a list that is anohter list.  For that matter, you
cannot have a component of anything that isn't a scalar.  You want
to make lists a viable thing for a scalar to hold?  That breaks the
model.  You can use parens as much or as little as you want and it
makes no different.  It also makes no sense to try to produce a
list when there's obviously no room for it.  You're in scalar
context.  Not only can you not put a list there, you can't even
being to THINK about there being a list in the vicinity.

>Perhaps that's my block. For me the return takes away the thrust of the
>outside scalar context.

Well, that's not how Perl works.  It really seems that there's some
mismatch between how Perl works and how you think it works.  It's
pretty dang important.  Perhaps you've forgotten this text:

    You will be miserable until you learn the difference between
    scalar and list context, because certain operators know which
    context they are in, and return a list in contexts wanting a
    list, but a scalar value in contexts wanting a scalar.

It sounds that you've not yet eradicated the misery of, well, if
not ignorance, then at least of misunderstanding as far as it
goes to how this context thing works.

--tom

Reply via email to