Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

stefp wrote:

Some people consider using map on empty context is bad form. I don't.

I think it depends on the context. If you're doing a short one-liner like that, it's not a big deal. In fact, if you're just writing a small "throw away" script that only gets used once or twice and you don't care about performance or memory, then it's not a big deal IMHO. However, if you're writing large applications, it pays to be rigorous. Creating a bunch of only to throw away the return value is a waste of resources and a for loop is preferable. Doing what you did to print all the files in the $HOME/MAIL/ directory:

# print all files in the directory (an overblown and limited 'ls' +or 'dir' perl -e '-f $_ and print "$_ " for glob(shift)' ./*

Side note: since I tested that on a Windows box and it doesn't like single quotes on the command line and I hate using \" all the time to embed quotes, I wrote this:

perl -e "-f $_ and print $_.$,.$/ for glob(shift)" ./*

No wonder people say Perl has too much punctuation :)

Cheers,
Ovid

Update: Hmm... seems I wasn't paying attention to blakem's post.

Vote for paco!

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re(2): Another Q about piping Perl by Ovid
in thread Another Q about piping Perl by Elvis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2022-05-20 08:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (73 votes). Check out past polls.

    Notices?