[EMAIL PROTECTED] (Tarak Parekh) writes:
> package A
>
> use strict;
>
> my @arr;
>
> sub new
> {
> my $classname = shift;
> my $self = {
> 'cfg_file' => undef,
> @_,
> };
>
> # Mark it of the right type
> bless ($self, $classname);
>
> # Initialize the arrays
> my $i = 0;
> for ($i = 0; $i < 4; $i += 1) {
> $arr[$i] = $i;
> }
>
> return $self;
> }
>
> sub num_get
> {
> my $self = shift;
> my ($type) = @_;
>
> eval {
> no strict ;
> return $#type;
> }
> }
>
> --- Client code
>
> use A;
>
> my $try = A -> new ("something");
>
> print $try -> num_get ('arr');
What are you trying to do here? Your answer will help
refine the help you get.
Lacking that answer, I'll take a stab in the dark.
Are you trying to find the last index (or size?) of the
package gloabl @arr array? If so, you're seemingly busting
encapsulation by letting (requiring) your client know the
name of an internal member. Keep it balck-box like this
sub size_of_internal_encapsulated_member {
return scalar @arr;
}
Because this is a class method, it's not even necessary to
pull off the $self parameter. The purpose of the method is
just to encapsulate the implementation.
--
Michael R. Wolf
All mammals learn by playing!
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]