KimberTLE has asked for the wisdom of the Perl Monks concerning the following question:
Having difficulty coming-up with what the prototype for my sub might look like. If coded as is (below), the sub works; the caller sends named parameters, the sub checks for useful data, does the caller's bidding.
A sample of things I've tried for prototypes are:
My actual code without the prototype resembles this:sub ConfigRead($ @ %); sub ConfigRead(;$ @ %); sub ConfigRead($ \@ \%); sub ConfigRead(;$ \@ \%);
Suggestions, solutions and/or winning lottery ticket numbers for Wednesday's drawing gratefully accepted!#!/usr/bin/perl -w use strict; my @aFieldHeaders; my %hFieldConfigs; my $sConfigFile = 'mydata.csv'; ConfigRead(sFILE => $sConfigFile, apHEAD => \@aFieldHeaders, hpFIELDCONF => \%hFieldConfigs); # my array and hash now have some cool stuff in 'em! sub ConfigRead { my %hArgs = ( sFILE => 'BAD', # lazy user alert! whine & die apHEAD => 'BAD', # ^^^ see comment above hpFIELDCONF => 'BAD', # by now you know the drill! @_, # user demands come from here ); # stick some cool stuff in their variables }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Function Prototypes
by GrandFather (Saint) on Nov 24, 2015 at 02:02 UTC | |
| |
Re: Function Prototypes
by hippo (Bishop) on Nov 24, 2015 at 13:21 UTC | |
by KimberTLE (Initiate) on Nov 24, 2015 at 18:19 UTC | |
by Your Mother (Archbishop) on Nov 24, 2015 at 18:32 UTC | |
by KimberTLE (Initiate) on Nov 25, 2015 at 02:21 UTC | |
by AnomalousMonk (Archbishop) on Nov 25, 2015 at 05:10 UTC | |
Re: Function Prototypes
by muba (Priest) on Nov 24, 2015 at 01:37 UTC | |
Re: Function Prototypes
by Anonymous Monk on Nov 24, 2015 at 01:48 UTC | |
Re: Function Prototypes
by Anonymous Monk on Nov 24, 2015 at 01:32 UTC | |
by KimberTLE (Initiate) on Nov 24, 2015 at 01:56 UTC | |
by GrandFather (Saint) on Nov 24, 2015 at 02:21 UTC | |
by Discipulus (Canon) on Nov 24, 2015 at 08:58 UTC | |
by AnomalousMonk (Archbishop) on Nov 24, 2015 at 05:14 UTC | |
Re: Function Prototypes
by u65 (Chaplain) on Nov 24, 2015 at 12:32 UTC | |
by davies (Prior) on Nov 24, 2015 at 13:25 UTC | |
by u65 (Chaplain) on Nov 24, 2015 at 14:02 UTC |
Back to
Seekers of Perl Wisdom