in reply to Passing a variable to a module

If you call a subroutine as a method (which is what you are doing her), the first argument will be the object or class name. Since you're calling it on an object, the object will be the first argument. The object is a blessed hash, and that's exactly what you print out. You want to print the second argument, not the first.

Replies are listed 'Best First'.
Re^2: Passing a variable to a module
by ikegami (Patriarch) on Oct 31, 2008 at 03:34 UTC
    The resulting code is:
    sub htmlHead { my $self = shift; # <------ my $title = shift; print $cgi->header("text/html"); print $title; print "<br>"; }
      I actually ended up using:

      sub htmlHead { my $title = $_[1]; print $cgi->header("text/html"); print $title; print "<br>"; }

      Thank you both for your help
      Rich