umasuresh has asked for the wisdom of the Perl Monks concerning the following question:
I get the expected output. Array dereferencing can be quite expensive and I wanted to refine the code further.my $variable = my_subroutine(\@my_array); sub my_subroutine { my $array = shift; # involves dereferencing the array_reference ... return(\$variable); }
Problemmy $variable = my_subroutine(\$array_start_idx, \$array_end_idx); sub my_subroutine { my $start_idx = shift; my $end_idx = shift; # involves accessong the global array using the indices passed ... return(\$variable); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pass an array reference or array indices to a subroutine?
by ikegami (Patriarch) on Feb 24, 2011 at 20:54 UTC | |
by umasuresh (Hermit) on Feb 24, 2011 at 21:01 UTC | |
by chromatic (Archbishop) on Feb 24, 2011 at 21:38 UTC | |
by ikegami (Patriarch) on Feb 24, 2011 at 22:13 UTC | |
by ikegami (Patriarch) on Feb 24, 2011 at 21:06 UTC | |
|
Re: Pass an array reference or array indices to a subroutine?
by JavaFan (Canon) on Feb 24, 2011 at 22:16 UTC | |
|
Re: Pass an array reference or array indices to a subroutine?
by GrandFather (Saint) on Feb 24, 2011 at 21:07 UTC | |
|
Re: Pass an array reference or array indices to a subroutine?
by umasuresh (Hermit) on Feb 24, 2011 at 22:41 UTC |