/[cvs]/nfo/perl/libs/Data/Mungle/Transform/String.pm
ViewVC logotype

Annotation of /nfo/perl/libs/Data/Mungle/Transform/String.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sun Jan 19 03:27:36 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
+ initial check-in

1 joko 1.1 ## ---------------------------------------------------------------------------
2     ## $Id$
3     ## ---------------------------------------------------------------------------
4     ## $Log$
5     ## ---------------------------------------------------------------------------
6    
7    
8     package Data::Transform::String;
9    
10     use strict;
11     use warnings;
12    
13     require Exporter;
14     our @ISA = qw( Exporter );
15     our @EXPORT_OK = qw(
16     stripHtml stripSpaces stripNewLines toReal trim
17     );
18    
19     sub stripHtml {
20     my $html = shift;
21     my $result = '';
22     #$html =~ s/<br>(.*)/ - ($1)/i;
23     my $p = HTML::PullParser->new(
24     doc => \$html,
25     text => 'text',
26     unbroken_text => 1,
27     );
28     while (my $token = $p->get_token()) {
29     my $text = join('', @{$token});
30     $result .= $text;
31     }
32     #$result =~ s/&nbsp;//g;
33     return $result;
34     }
35    
36     sub stripSpaces {
37     my $text = shift;
38     #print "text: $text", "\n";
39     #print "ord: ", ord(substr($text, 0, 1)), "\n";
40     $text =~ s/^\s*//g;
41     $text =~ s/\s*$//g;
42     return $text;
43     }
44    
45     sub trim {
46     my $string = shift;
47     return stripSpaces($string);
48     }
49    
50     sub stripNewLines {
51     my $text = shift;
52     #print "text: $text", "\n";
53     #print "ord: ", ord(substr($text, 0, 1)), "\n";
54     $text =~ s/\n//g;
55     #$text =~ s/\s*$//g;
56     return $text;
57     }
58    
59     sub toReal {
60     my $string = shift;
61     $string =~ m/(\d+\.*\d+)/;
62     my $real = $1;
63     return $real;
64     }
65    
66     1;

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed