<start_html>
<pre>
<perl handler="handler1"/>
<perl handler="handler2"/>
<perl handler="handler3"/>
<perl handler="handler4"/>
<perl handler="handler5" chomp/>
<perl handler="handler6"/>
<perl handler="handler7"/>
__PERL__

#  Different ways of sending output to the browser
#
sub handler1 {

    #  Simplest - just returm a scalar variable
    #
    my $text='Hello World 1';
    return $text;
    
}

sub handler2 {

    #  Scalar ref better because if var is empty (undef) won't trigger and error
    #
    my $text='Hello World 2';
    return \$text;
    
}

sub handler3 {

    #  You can print something also using the print statement
    #
    my $text='Hello World 3';
    print $text;
    print "\n";
    
    #  Printing a scalar ref is OK
    #
    print \$text;
    
}

sub handler4 {

    #  You can print arrays
    #
    my @text=('Hello ', 'World ', 4);
    print @text;
    
    
    #  Print new line manually, or turn on autonewline -
    #  see next example;
    #
    print "\n";
    
    #  Array refs are OK
    #
    print \@text;
    
    
    #  Printing hash ref's won't work ! This will fail
    #
    # print { a=>1, b=>2 }
    return \undef;
    
}

sub handler5 {

    #  You can print using a webdyne method handler
    #
    my $self=shift();
    
    
    #  Text we want to print
    #
    my $text="Hello World 5\n";
    my @text=('Hello ', 'World ', 5, "\n");
    
    
    
    #  These all work
    #
    $self->print($text);
    $self->print(\$text);
    $self->print(@text);
    $self->print(\@text);
    return \undef;
    
}


sub handler6 {

    #  You can print using a webdyne method handler
    #
    my $self=shift();
    
    
    #  Text we want to print
    #
    my $text="Hello World 6";
    my @text=('Hello ', 'World ', 6);
    
    
    #  Turn on autonew line to print "\n" at end of every call
    #
    $self->autonewline(1);
    
    
    #  These work
    #
    $self->print($text);
    $self->print(\$text);
    
    
    #  These put a CR between every element in the array
    $self->print(@text);
    $self->print(\@text);
    
    
    #  Turn off autonewline and return
    #
    $self->autonewline(0);
    return \undef;
    
}


sub handler7 {

    #  The say() method is supported also
    #
    use feature 'say';
    my $self=shift();
    my $text='Hello World 7';
    
    
    #  These will print, but won't send newline - say() won't send \n to TIEHANDLE
    #
    say($text);
    say($text);
    $self->print("\n");
    
    
    #  Use this instead
    #
    $self->say($text, $text);
}
