Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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

by l2kashe (Deacon)
on Aug 07, 2003 at 03:39 UTC ( #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;
    screwed "$_" for @instances; even less typing again!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-08-15 13:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found