perlmonkey wrote: I certainly would not guess that scalar(sort @a) would return the last element, so I am glad that it doesnt, but apparently you think it should.

From man perldata:

In a context not requiring a list value, the value of the list literal is the value of the final element, as with the C comma operator. For example, @foo = ('cc', '-E', $bar); assigns the entire list value to array foo, but $foo = ('cc', '-E', $bar); assigns the value of variable bar to variable foo.
Also:
If you evaluate a named array in a scalar context, it returns the length of the array. (Note that this is not true of lists, which return the last value...
From man perlfunc:
sort LIST
Sorts the LIST and returns the sorted list value.

So, you see, since sort returns "the sorted list value," and lists evaluate to "the value of the final element," I would expect (at first glance) to get the last element from the list which sort returns.

BTW, I hope I didn't offend you somehow. If so, I am terribly sorry. Your response seemed a bit hostile. Please accept my apologies...

Just a nice guy trying to contribute,
Russ


In reply to RE: RE: RE: Re: scalar doesn't work values returned by a function? by Russ
in thread scalar doesn't work values returned by a function? by ZZamboni

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.