"Fossies" - the Fresh Open Source Software Archive

Member "HTML-Stream-1.60/examples/giggles" (17 Aug 2001, 1456 Bytes) of package /linux/www/old/HTML-Stream-1.60.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 =head1 NAME
    3 
    4 giggles - just some example code using HTML::Stream
    5 
    6 =cut
    7 
    8 
    9 BEGIN {
   10     unshift @INC, "..";
   11 }
   12 
   13 package StringHandle;
   14 sub new {
   15     my $self = '';
   16     bless \$self, shift;
   17 }
   18 sub print {
   19     my $self = shift;
   20     $$self .= join('', @_);
   21 }
   22 
   23 
   24 package main;
   25 use HTML::Stream;
   26 use FileHandle;
   27 
   28 my $SH = new StringHandle;
   29 my $HTML = new HTML::Stream $SH;
   30 $HTML -> H1 -> t("<Hello & welcome!>") -> _H1;
   31 print "PRINTED STRING: ", $$SH, "\n";
   32 
   33 my $HTML = new HTML::Stream;
   34 $HTML -> H1 -> t("none") -> _H1;
   35 
   36 my $HTML = new HTML::Stream \*STDOUT;
   37 $HTML -> H1 -> t("<\\*STDOUT>") -> _H1;
   38 
   39 my $HTML = new HTML::Stream 'STDOUT';
   40 $HTML -> H1 -> t("STDOUT") -> _H1;
   41 
   42 my $HTML = new HTML::Stream 'main::STDOUT';
   43 $HTML -> H1 -> t("main::STDOUT") -> _H1;
   44 
   45 my $fh = new FileHandle ">&STDOUT";
   46 my $HTML = new HTML::Stream $fh;
   47 $HTML -> H1 -> t("FD 0") -> _H1;
   48 
   49 
   50 
   51 package MY::HTML;
   52 
   53 @ISA = qw(HTML::Stream);
   54      
   55     sub Aside {
   56     $_[0] -> FONT(SIZE=>-1) -> I;
   57     }
   58     sub _Aside {
   59     $_[0] -> _I -> _FONT;
   60     }
   61 
   62 package main;
   63 
   64 use HTML::Stream qw(:funcs);
   65 
   66     my $HTML = new MY::HTML \*STDOUT;
   67     
   68     $HTML -> Aside
   69           -> t("Don't drink the milk, it's spoiled... pass it on...")
   70           -> _Aside;
   71 
   72     $HTML -> nl -> comment("Hey\nthere") -> comment("Ho");
   73 
   74 my $htmlstr = "<I>Hi</I> &amp; 360&#176;\n";
   75 print "Raw:        ", $htmlstr;
   76 print "Unescaped:  ", html_unescape($htmlstr);
   77 print "Unmarkedup: ", html_unmarkup($htmlstr);
   78 
   79 
   80 1;
   81