Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: RE: Map: The Basics

by swiftone (Curate)
on Jan 12, 2001 at 02:22 UTC ( [id://51232]=note: print w/replies, xml ) Need Help??


in reply to RE: Map: The Basics
in thread Map: The Basics

my @array = <FILE>; map s/\#.*$//, @array;
This way of doing things is deliberate, as it eliminates unnecessary assignments when you want the results to go back to the same array.

Except that he explicitly said that if you aren't using the list returned, you shouldn't use map, you should look into another looping structure, such as:

my @array = <FILE>; s/\#.*$// foreach @array;
To do otherwise obfuscates the purpose of your loop.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-06-25 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.