/[cvs]/nfo/perl/libs/libp.pm
ViewVC logotype

Diff of /nfo/perl/libs/libp.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by cvsjoko, Thu Jun 27 02:14:22 2002 UTC revision 1.14 by joko, Sun Feb 9 04:49:09 2003 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.14  2003/02/09 04:49:09  joko
7    #  - purged lots of code and refactored into other modules
8    #  - sorry!
9    #
10    #  Revision 1.13  2002/12/23 04:25:13  joko
11    #  + sub bool2status
12    #
13    #  Revision 1.12  2002/12/22 14:15:02  joko
14    #  + sub mkObject
15    #
16    #  Revision 1.11  2002/12/19 16:27:17  joko
17    #  +- renamed 'cmd' to 'run_cmd'
18    #
19    #  Revision 1.10  2002/12/19 01:05:35  joko
20    #  + sub today
21    #
22    #  Revision 1.9  2002/12/05 13:54:00  joko
23    #  + fix: let 'deep_copy' print its message out (instead of die)
24    #
25    #  Revision 1.8  2002/12/01 22:11:35  joko
26    #  + sub cmd
27    #  + sub run_cmds
28    #
29    #  Revision 1.7  2002/11/29 04:44:53  joko
30    #  - sub array_getRelations
31    #  + sub getNewPerlObjectByPkgName
32    #
33    #  Revision 1.6  2002/11/17 07:18:59  joko
34    #  + sub deep_copy
35    #
36    #  Revision 1.5  2002/10/27 18:34:28  joko
37    #  + sub now
38    #
39    #  Revision 1.4  2002/08/16 19:06:39  cvsjoko
40    #  + sub getDirList
41    #
42    #  Revision 1.3  2002/07/19 18:13:50  cvsjoko
43    #  no message
44    #
45  #  Revision 1.2  2002/06/27 02:14:22  cvsjoko  #  Revision 1.2  2002/06/27 02:14:22  cvsjoko
46  #  + stripHtml stripSpaces stripNewLines toReal  #  + stripHtml stripSpaces stripNewLines toReal
47  #  #
# Line 14  Line 53 
53    
54  package libp;  package libp;
55    
 require Exporter;  
 @ISA = qw( Exporter );  
 @EXPORT = qw(  
   Dumper  
   md5 md5_hex md5_base64  
   ParseDate UnixDate  
     
   stripHtml stripSpaces stripNewLines toReal  
 );  
   
56  use strict;  use strict;
57  use warnings;  use warnings;
58    
59  use Data::Dumper;  require Exporter;
60  use Digest::MD5 qw(md5 md5_hex md5_base64);  our @ISA = qw( Exporter );
61    our @EXPORT_OK = qw(
62        ParseDate UnixDate
63        array_getDifference
64        bool2status
65    );
66    
67  $main::TZ = 'GMT';  $main::TZ = 'GMT';
68  use Date::Manip;  use Date::Manip;
69    
 require LWP::UserAgent;  
 use HTML::PullParser;  
   
70    
71  ########################################  ########################################
72    
 sub stripSpaces {  
   my $text = shift;  
   #print "text: $text", "\n";  
   #print "ord: ", ord(substr($text, 0, 1)), "\n";  
   $text =~ s/^\s*//g;  
   $text =~ s/\s*$//g;  
   return $text;  
 }  
73    
 sub stripNewLines {  
   my $text = shift;  
   #print "text: $text", "\n";  
   #print "ord: ", ord(substr($text, 0, 1)), "\n";  
   $text =~ s/\n//g;  
   #$text =~ s/\s*$//g;  
   return $text;  
 }  
74    
 sub toReal {  
   my $string = shift;  
   $string =~ m/(\d+\.*\d+)/;  
   my $real = $1;  
   return $real;  
 }  
75    
76  sub stripHtml {  
77    my $html = shift;  # =============================================
78    my $result = '';  
79    #$html =~ s/<br>(.*)/ - ($1)/i;  
80    my $p = HTML::PullParser->new(  sub bool2status {
81      doc => \$html,    my $bool = shift;
82      text => 'text',    return ($bool ? 'ok' : 'failed');
     unbroken_text => 1,  
   );  
   while (my $token = $p->get_token()) {  
     my $text = join('', @{$token});  
     $result .= $text;  
   }  
   #$result =~ s/&nbsp;//g;  
   return $result;  
83  }  }
84    
85  1;  1;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.14

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