|Just another Perl shrine|
Re: passing paramters to a subby jimbus (Friar)
|on Aug 30, 2005 at 15:17 UTC||Need Help??|
I picked up perl, initially, from hacking other people's code. I came back to it recently because of the frustration of using stock Unix shells to parsing logs and have been working out of O'Reily's Perl Cookbook and google searches.
If you've read some of my other post, you've probably heard me rant about not being able to find best practices and perl patterns. This kind of falls into that category. I spent more than a half hour going through the book and googling for "perl sub parameters" and "perl sub parameters hashes" and couldn't find anything that did something as basic pass multiple parameters. I really haven't needed to use subs, but I probably should get into the habit again, to improve readability. Scanning through the PerlDoc page listed, I found the section discussing passing multiple data structures by reference... something else I've been avoiding and need to embrace, using references.
Perhaps there's a better way to do what I'm doing? I have to compare filenames in a CSV with an actualy directory listing. I'm comfortable with parsing the CSV and populating a hash with the filenames and the value 1. I 'm comfortable with ftping to the remote machine and getting a list of files and updateing the hash with += 2, so that I end up with a 1, 2 or 3 for each member, depending on whether the file is in one, the other or both. What I think is messy is the reporting. I'm basically walking through the hash three times to say print each 3, print each 2, print each 1. Is there a more efficient way to pull this off?
Never moon a werewolf!