pravlm has asked for the wisdom of the Perl Monks concerning the following question:
but how to pass the literal array itself instead of creating a temporary array variable, just like we do in C++.# Note here its just one element but it can be more my @aTmpArray=qw("CheckSDKDir()"); WriteToFile(\@aTmpArray); ..... sub WriteToFile($@) { my ($aRefArray) = $_[0]; #Checking if the array is initialized if($aRefArray->[0]) { printf( join(" ", @$aRefArray); } }
It may sound silly but I am curious to know if its possible in Perl? Thanks MonksWriteToFile(\@qw("abc", "23343")); #Error here!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to pass array literal through pass by reference
by kennethk (Abbot) on Mar 16, 2009 at 19:39 UTC | |
by pravlm (Acolyte) on Mar 16, 2009 at 20:08 UTC | |
by kennethk (Abbot) on Mar 16, 2009 at 20:29 UTC | |
by kyle (Abbot) on Mar 16, 2009 at 21:08 UTC | |
|
Re: How to pass array literal through pass by reference
by kyle (Abbot) on Mar 16, 2009 at 19:52 UTC | |
by pravlm (Acolyte) on Mar 16, 2009 at 20:26 UTC |