Erik W <[EMAIL PROTECTED]> asked:
 
: Is [there] a way to pass the reference of an
: object to subroutine?

    Yes, but an object already is a reference. A
reference to an object would be a reference to a
reference.

: Maybe I am trying to do something stupid and
: unnecessary here, but I would like to know if
: it is possible, how to do it?

    use CGI;
    my $q = CGI->new();

    push @page, start( $q, $title );

    sub start {
        my( $object, $title ) = @_;
        return
                $object->header(),
            $object->start_html( -title => $title );
    }


: Why is it stupid? Is there a
: better way?  Thanks a lot!

    Basically, there are three choices: the one
used above, a global object, and a private
object. Using "use strict;" at the top of your
script may help you catch typos. I prefer the
third choice when possible and the first one
normally. I tend to avoid anything that looks
like a global which isn't a constant.

    use CGI;
    my $q = CGI->new();

    push @page, start( $title );

    sub start {
        my $title = @_;
        return
                $q->header(),
            $q->start_html( -title => $title );
    }


    use CGI;

    push @page, start( $title );

    sub start {
        my $q = CGI->new();

        my $title = shift;
        return
                $q->header(),
            $q->start_html( -title => $title );
    }

: 
: Here is the scripts:
: 
: $CGI=new CGI;
: test(\$CGI);
:  sub test {
:       my ($CGI)[EMAIL PROTECTED];
: print $CGI->header(),
: $cgi->start_html(),

    Perl is case-sensitive $CGI and $cgi are
two _different_ variables.

HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to