You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Christopher L. Everett" <ce...@ceverett.com> on 2001/02/06 09:18:27 UTC

Help: Can't use string ("Exchange::Account::My") as a HASH ref while "strict refs" in use trying to use instance variables in my handler

This is my code:

##
## Exchange::Account::My - Account Admin module for the Banner Exchange
##
package Exchange::Account::My;

use strict;

use Apache;
use Apache::Request;
use Apache::Constants qw( :common REDIRECT );
use Apache::Cookie;
use DBI;
use Data::Dumper;
use MD5;

my $debug_level = 3;

sub handler ($$) {
  my ($self, $q) = @_;

  my $r    = Apache::Request->new($q);

  $self->child_init unless $self->{_child_started_up};  # <==== dies
here!
  
  my $self->{frame}   = $r->param('frame')   ||
$self->{config}->{Start_Frame};
  my $self->{page}    = $r->param('page')    ||
$self->{config}->{Start_Page};
  my $self->{command} = $r->param('command') ||
$self->{config}->{Start_Command};
  my $uri             = $r->uri;

  $r->log_error(qq/accessing $uri with params:
frame=$self->{frame}\&page=$self->{page}\&command=$self->{command};/) if
$debug_level > 0;

  $self->{session} = $self->get_session($r);

  my $html;
  if (my $coderef = $self->dispatch($self->{frame}, $self->{page},
$self->{command})) {
    $html = $self->$coderef($r);
    $self->put_or_del_session($r);
  } else {
    $html = '';
    $r->log_reason(qq/Some bozo tried to access $uri with params:
frame=$self->{frame}\&page=$self->{page}\&command=$self->{command};/);
    $self->logout($r);
  } 
  
  $r->content_type('text/html');
  $r->no_cache(1);
  $r->send_http_header;
  print $html;
  return OK;
}

sub init {
  my $invocant = shift;
  my $class = ref ($invocant) || $invocant;
  my $self = {};
  bless ($self, $class);

  $self->{config}    = $self->init_config;
  $self->{dispatch}  = $self->init_dispatch_table;
  $self->{templates} = $self->init_templates;
  $self->{_child_started_up} = 0;
  
  return $self;
}
================================================================================================

I'm dying here ... I want to Do The Right Thing and use instance
variables, 
but my code only works uder mod_perl when I use class variables.  This
can't
be the way it was meant to be ...

Christopher Everett