Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Generating a List of numbers

by aaron_baugher (Curate)
on Feb 01, 2012 at 23:45 UTC ( #951318=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Generating a List of numbers
in thread Generating a List of numbers

You may think you want to have a loop inside a loop, but you really don't. Not with Perl. When a problem sounds like, "I want to look through file1 for records matching strings found in file2," the Perl programmer immediately thinks, "So I put the strings from file2 into a hash as the keys, and then loop through file1 checking to see if each line matches a key in my hash."

Perl's hashes just make that algorithm so handy that it doesn't make sense to do it with nested loops unless a hash won't work for some reason, which isn't the case here. Or unless your homework assignment says, "Do this with nested loops," in which case you need a new Perl teacher.

Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.


Comment on Re^4: Generating a List of numbers

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (17)
As of 2015-07-28 18:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls