On Saturday 25 September 2010 11:00:50 feltra wrote:
> Hi,
>
> Am using arrays with only references in a sub-routine. While I got
> the hang of how to access an element of the array using the '->'
> operator, I do not know how to intialize this array. I.e. I want to
> be able to do something like
>
> @myarr=(); $#myarr = -1;
>
> inside the subroutine, but myarr is only a reference to an array not
> the actual array...
You can do something like:
sub my_subroutine
{
my ($array_ref) = @_;
@$array_ref = ();
$#{$array_ref} = -1;
}
Assuming this is what you meant by array reference. For more information see:
http://perl-begin.org/topics/references/
Regards,
Shlomi Fish
>
> Hope the above problem description is clear.
>
> If anyone knows how to do this, kindly help by posting the answer or
> tell me where to look...
>
> Thanks & Best Regards,
> -feltra
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
What does "Zionism" mean? - http://shlom.in/def-zionism
<rindolf> She's a hot chick. But she smokes.
<go|dfish> She can smoke as long as she's smokin'.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/