Hello! I've started learning Perl this weekend (read Learning Perl and am making my way through Intermediate Perl now), and was quite drawn in by what seems to be a very strong community. The concept of this site makes me warm and fuzzy :)

I'd like to learn Perl in "the Perl way," as I know such styles exist for a reason and help to improve readability among other programmers of the language. So comments about style in addition to actual functionality would be appreciated.

I have a general question, involving the optional nature of parentheses, and an example of said question has arisen in this little exercise from the book that I'm doing.
"Write a program that takes a list of filenames on the command line and uses grep to select the ones whose size in bytes is less than 1000. Use map to transform the strings in this list, putting four space characters in front of each and a newline character after. Print the resulting list." (I increased the number to 10000 to easier accommodate files I had sitting on my desktop for testing purposes.)
Here's what I have:
use warnings; use strict; my @small_files = grep( (-s) < 10000, @ARGV); my @output = map s/(.*)/ $1\n/, @small_files; print @output;

First question is, of course: my isn't it working like I want? The grep seems to be fine, but the @output seems to contain 4 1's instead of 4 modified strings of filenames.
Second question: when I first wrote it, my grep statement looked like: my @small_files = grep -s < 10000, @ARGV;
But that had an error, so I had to put the parentheses in, which made me kinda sad. Why was that the case?
Thanks!
~J. (Just Another Perl Newbie?)

In reply to Newbie: parentheses, map, etc. by nefigah

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.