File: giggles

package info (click to toggle)
libhtml-stream-perl 1.60-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 388 kB
  • sloc: perl: 666; makefile: 2
file content (81 lines) | stat: -rwxr-xr-x 1,456 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/perl
=head1 NAME

giggles - just some example code using HTML::Stream

=cut


BEGIN {
    unshift @INC, "..";
}

package StringHandle;
sub new {
    my $self = '';
    bless \$self, shift;
}
sub print {
    my $self = shift;
    $$self .= join('', @_);
}


package main;
use HTML::Stream;
use FileHandle;

my $SH = new StringHandle;
my $HTML = new HTML::Stream $SH;
$HTML -> H1 -> t("<Hello & welcome!>") -> _H1;
print "PRINTED STRING: ", $$SH, "\n";

my $HTML = new HTML::Stream;
$HTML -> H1 -> t("none") -> _H1;

my $HTML = new HTML::Stream \*STDOUT;
$HTML -> H1 -> t("<\\*STDOUT>") -> _H1;

my $HTML = new HTML::Stream 'STDOUT';
$HTML -> H1 -> t("STDOUT") -> _H1;

my $HTML = new HTML::Stream 'main::STDOUT';
$HTML -> H1 -> t("main::STDOUT") -> _H1;

my $fh = new FileHandle ">&STDOUT";
my $HTML = new HTML::Stream $fh;
$HTML -> H1 -> t("FD 0") -> _H1;



package MY::HTML;

@ISA = qw(HTML::Stream);
     
    sub Aside {
	$_[0] -> FONT(SIZE=>-1) -> I;
    }
    sub _Aside {
	$_[0] -> _I -> _FONT;
    }

package main;

use HTML::Stream qw(:funcs);

    my $HTML = new MY::HTML \*STDOUT;
    
    $HTML -> Aside
          -> t("Don't drink the milk, it's spoiled... pass it on...")
          -> _Aside;

    $HTML -> nl -> comment("Hey\nthere") -> comment("Ho");

my $htmlstr = "<I>Hi</I> &amp; 360&#176;\n";
print "Raw:        ", $htmlstr;
print "Unescaped:  ", html_unescape($htmlstr);
print "Unmarkedup: ", html_unmarkup($htmlstr);


1;