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

Re: Versatile subs

by Roger (Parson)
on Sep 02, 2005 at 23:47 UTC ( #488817=note: print w/replies, xml ) Need Help??


in reply to Versatile subs

It depends on what you are trying to do. Do get_states, get_ids, etc., operate on the same set of files in your program?

It may be better if you just have a single sub that returns an array (or reference to an array) of file attributes, or whatever form best suits your application needs, in a manar similar to the stat function.

This way, you keep all your code in one spot, plus you have the added benefit of doing only a single pass on the file, instead of each sub doing a separate pass on the same file.

You can also pass in an optional parameter, say, -want => [ qw/ id states / ], so that you can tell the sub that you only want a subset of file hashes, otherwise the sub will return the complete set of file hashes.

Replies are listed 'Best First'.
Re^2: Versatile subs
by eff_i_g (Curate) on Sep 03, 2005 at 00:08 UTC
    Roger,

    Each sub works with a unique file.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://488817]
help
Chatterbox?
[Discipulus]: choroba i made you Bishop !!
[choroba]: 9999 points until level 23 - Archbishop.
[LanX]: darn trying to downvote him again fails ... ;-P
[Discipulus]: congrats!
[LanX]: His Excelleny Choroba will now nbe clothed in his new robe ...
[Discipulus]: bishop ship sheeps in the shop..
[1nickt]: Discipulus too easy!
[1nickt]: "The sixth sheik's sixth sheep's sick" (if you are after 'sh' tongue twisters)
[Discipulus]: ok try it in Eatalian ;=)
[Eily]: Discipulus I don't suppose you can do the same for me can you ? :P

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2017-09-26 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (294 votes). Check out past polls.

    Notices?