line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::CompressWhitespace; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::CompressWhitespace.pm |
11
|
|
|
|
|
|
|
# Description: Remove whitespace for web transmission |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 02/02/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 02/02/2005 Needed to reduce filesizes for more speed! |
17
|
|
|
|
|
|
|
# Ideally all pages should be less than 1300 MTU (allowing for |
18
|
|
|
|
|
|
|
# HTTP headers). |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################### |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
4889
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
179
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
############################################################################### |
26
|
|
|
|
|
|
|
# |
27
|
|
|
|
|
|
|
# compress_html - remove excess white space in html |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
############################################################################### |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub compress_html { |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
my ($string_ref) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# strip whitespace but preserve newlines |
36
|
|
|
|
|
|
|
# to avoid Javascript bugs |
37
|
0
|
0
|
|
|
|
|
$$string_ref =~ s{([\s\n]+)}{($1 =~ /\n/) ? "\n" : " "}eg; |
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# remove spaces around = signs |
40
|
0
|
|
|
|
|
|
$$string_ref =~ s/\s+\=\s+/=/g; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# strip single spaces between tags |
43
|
0
|
|
|
|
|
|
$$string_ref =~ s/\>\s\</\>\</g; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#return $string_ref; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Goo::CompressWhitespace - Remove excess whitespace |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Goo::CompressWhitespace; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item compress_html |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
remove excess whitespace in HTML and Javascript to reduce overall byte size |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SEE ALSO |
81
|
|
|
|
|
|
|
|