Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable "disappears" when debugging

Status
Not open for further replies.

fishiface

IS-IT--Management
Feb 24, 2003
687
GB
I've got a really simple object
Code:
package Doc::Page;
use strict;

# A page is a scalar containing the page data.
# It can be searched, processed and printed.

sub new {
        my $proto = shift;
        my $class = ref($proto) || $proto;
        my $page  = $_[0] ? shift : "";
        my $self  = \$page;
        bless($self, $class);
        return($self);
}

which works fine until I try to debug it under ptkdb. The call to bless clears the contents of $self and I'm left with an empty, blessed scalar. $page is still intact.

I've heard of variable suicide - it's mentioned in, eg, CGI.pm, but I don't know what causes it, how to avoid it or, indeed, whether that is what I'm seeing.

f

"As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilkes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top