Welcome to Dream.In.Code
Become an Expert!

Join 149,582 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,766 people online right now. Registration is fast and FREE... Join Now!




Five Sweet Perl Tips

 
Reply to this topicStart new topic

Five Sweet Perl Tips

girasquid
7 Oct, 2007 - 05:02 PM
Post #1

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
I just found this article:
Five great Perl programming techniques to make your life fun again, and I thought that I should share it. I think it's got some neat ideas, and I've only tried out 2 of them(although I'm currently brainstorming ideas for how to use the others in my projects). Has anyone tried all five?

This post has been edited by girasquid: 7 Oct, 2007 - 05:02 PM
User is offlineProfile CardPM
+Quote Post

KevinADC
RE: Five Sweet Perl Tips
7 Oct, 2007 - 09:29 PM
Post #2

D.I.C Head
Group Icon

Joined: 23 Jan, 2007
Posts: 238



Thanked: 6 times
Dream Kudos: 50
My Contributions
Nothing new in the article for me, but for a newer perl coder the tips are good.
User is offlineProfile CardPM
+Quote Post

Chubber
RE: Five Sweet Perl Tips
31 Oct, 2007 - 10:11 AM
Post #3

D.I.C Head
Group Icon

Joined: 16 Oct, 2006
Posts: 118


Dream Kudos: 225
My Contributions
He hits some of the good Perl tricks on the head. Even if you don't do it all, learn "map" and "$a ||= 5" trick and it will help you a lot.
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Five Sweet Perl Tips
31 Oct, 2007 - 01:07 PM
Post #4

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
Yeah, I have to say that I'm starting to drool over map (and a little more over grep, now that I can use it with map).
User is offlineProfile CardPM
+Quote Post

KevinADC
RE: Five Sweet Perl Tips
31 Oct, 2007 - 05:27 PM
Post #5

D.I.C Head
Group Icon

Joined: 23 Jan, 2007
Posts: 238



Thanked: 6 times
Dream Kudos: 50
My Contributions
QUOTE(girasquid @ 31 Oct, 2007 - 02:07 PM) *

Yeah, I have to say that I'm starting to drool over map (and a little more over grep, now that I can use it with map).



map and grep are great tools but don't use them unwisely. They both process an entire list and that is often not what you want to do. Use a "for" or "foreach" or "while" loop when you want to break out of a list while processing it. You can use: last, next, redo, with loops but not with map and grep. I am not sure, but I think map reads an entire list/file into memory, and that can lead to other problems if the list/file is big.
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Five Sweet Perl Tips
31 Oct, 2007 - 07:41 PM
Post #6

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
QUOTE(KevinADC @ 31 Oct, 2007 - 06:27 PM) *

QUOTE(girasquid @ 31 Oct, 2007 - 02:07 PM) *

Yeah, I have to say that I'm starting to drool over map (and a little more over grep, now that I can use it with map).



map and grep are great tools but don't use them unwisely. They both process an entire list and that is often not what you want to do. Use a "for" or "foreach" or "while" loop when you want to break out of a list while processing it. You can use: last, next, redo, with loops but not with map and grep. I am not sure, but I think map reads an entire list/file into memory, and that can lead to other problems if the list/file is big.


Thanks for the tip; I'll keep that in mind.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 10:46PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month