Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: opening a file destroys nulling entries in a list?!?!

by l2kashe (Deacon)
on Aug 07, 2003 at 03:39 UTC ( [id://281730]=note: print w/replies, xml ) Need Help??


in reply to opening a file destroys nulling entries in a list?!?!

and now for something entirely different..

just as an aside, using map in a void context (i.e. not returning anything), is generally considered a BadThing(TM). If you are simply looking for a way to do simple single line loops, you can always use for().. ala

print "before: $_\n" for @instances; screwed "$_" for @instances; print "after: $_\n" for @instances;

You might already know this, you might not, but I figured I would toss it out there. The reason it't not so good, is Perl can go through a lot of trouble to build a list of things to return from the map block, and if you don't use them its simply a waste of processor time and memory that could be better spent doing other things.

use perl;

Replies are listed 'Best First'.
Re: Re: opening a file destroys nulling entries in a list?!?!
by matpalm (Initiate) on Aug 07, 2003 at 03:47 UTC
    my first attempt was with
    foreach(@instances) { screwed "$_"; };
    and then when it didn't work i showed it to someone here at work and he introduced me to maps so i used
    map { screwed "$_"; } @instances;
    but...
    screwed "$_" for @instances;
    ..is even less typing again!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://281730]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-26 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found