On Tue, 2006-06-06 at 12:14 -0500, [EMAIL PROTECTED] wrote:
> I'm trying to debug a failing script.  It is chock full of expressions
> like this:
>   $self->_read_file($self->{file})
> 
> I have never used this syntax in my own scripts which are pretty basic
> and getting a headache trying to figure out what that line is saying.
> 
> One of the @_ array being passed to the sub `_read_file' referred to
> in the line above:
> 
>        my $file = shift;
> 
> is ending up undefined so trying to track down where it gets defined.
> I think it is in the above line but I'm not getting what is being
> pointed to.
>  

Congratulations, you have discovered Object-Oriented Perl. For a brief
introduction, read:

           perlboot            Perl OO tutorial for beginners
           perltoot            Perl OO tutorial, part 1
           perltooc            Perl OO tutorial, part 2
           perlbot             Perl OO tricks and examples

Basically, $self is a reference to a hash that has been blessed to an
object. The line:

  $self->_read_file($self->{file});

means call the method _read_file() of the object referred to by $self
using the the value of the key 'file' of the hash referred to by self.
Since the method starts with an underscore, it is, by convention,
considered to be an auxiliary method; which means it should only be
called from other methods within the object.

To see what's inside $self:

  use Data::Dumper;
  print Dumper $self;

You may also want to add (before the print):

  $Data::Dumper::Maxdepth = 0;

A Maxdepth of zero, means show the whole thing, which can be very long,
so you may want to limit it to 2 or 3 so that it's easier to read.


-- 
__END__

Just my 0.00000002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to