mascip has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
how should i do this in Perl :
foreach $sub ( @sub_names ) { sub $sub { #subroutine implementation } }
I'm reading a spreadsheet where there are 19 columns, 14 of which i'm interested in (i'll take the column "LIGHT" as an example). And i'd like to create subroutines with appropriate names, to read each of them.
I know that i could have one subroutine which would take the name of the column as a parameter, like this:
But in terms of external API, this seems more readable :read('light',10); # Retrieve the value of "light" at line 10 read_at_time('light', $timestamp);
So, how should i implement this?light(10); # Retrieve the value of "light" at line 10 light_at_time($timestamp);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a loop for creating subroutines?
by LanX (Saint) on Aug 27, 2012 at 16:33 UTC | |
by mascip (Pilgrim) on Aug 27, 2012 at 16:43 UTC | |
by LanX (Saint) on Aug 27, 2012 at 16:49 UTC | |
|
Re: a loop for creating subroutines?
by Anonymous Monk on Aug 27, 2012 at 19:20 UTC | |
|
Re: a loop for creating subroutines?
by philiprbrenan (Monk) on Aug 27, 2012 at 19:29 UTC | |
by mascip (Pilgrim) on Aug 27, 2012 at 19:58 UTC | |
by philiprbrenan (Monk) on Aug 27, 2012 at 20:52 UTC | |
by LanX (Saint) on Aug 28, 2012 at 08:47 UTC | |
by Anonymous Monk on Aug 28, 2012 at 06:58 UTC |