Ok. That code makes no sense. Let's disect it:
  1. my VAR ... This creates a lexical variable within the innermost scope you're in. In this case, it creates an array called @d.
  2. = ... assignment operator (but, you knew that)
  3. sort LIST ... Takes a list (or array which it converts to a list, but that's unimportant) which can be named or unnamed. In this case, it takes a list called @d, which has to have been defined earlier (at least, for it to make sense).
Now, you can do something like @d = sort @d; which basically means that you want to do an ASCII sort the values within @d and then store the result within @d. But, by having the my there, it doesn't make any sense.

If you put -w on your shebang line, you'd see a redefinition of @d warning.

As for it being unPerl-like, it's not. You may be used to a lot of in-place operators, and that's not C-like. But, sort doesn't work in-place, primarily because you often want to sort an array, then put the sorted result into another array.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to Re: UnPerl-like Code by dragonchild
in thread UnPerl-like Code by jerrygarciuh

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.