Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: passing paramters to a sub

by jimbus (Friar)
on Aug 30, 2005 at 15:17 UTC ( #487798=note: print w/replies, xml ) Need Help??

in reply to passing paramters to a sub

Thanks all!

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?

Thanks again!


Never moon a werewolf!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://487798]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2017-02-26 15:09 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (375 votes). Check out past polls.