/[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.3 by cvsjoko, Fri Jul 19 18:13:50 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.3  2002/07/19 18:13:50  cvsjoko
7    #  no message
8    #
9  #  Revision 1.2  2002/06/27 02:14:22  cvsjoko  #  Revision 1.2  2002/06/27 02:14:22  cvsjoko
10  #  + stripHtml stripSpaces stripNewLines toReal  #  + stripHtml stripSpaces stripNewLines toReal
11  #  #
# Line 17  package libp; Line 20  package libp;
20  require Exporter;  require Exporter;
21  @ISA = qw( Exporter );  @ISA = qw( Exporter );
22  @EXPORT = qw(  @EXPORT = qw(
23    Dumper      Dumper
24    md5 md5_hex md5_base64      md5 md5_hex md5_base64
25    ParseDate UnixDate      ParseDate UnixDate
26          strftime
27    stripHtml stripSpaces stripNewLines toReal      stripHtml stripSpaces stripNewLines toReal trim
28        croak
29        array_getDifference
30  );  );
31    
32  use strict;  use strict;
# Line 36  use Date::Manip; Line 41  use Date::Manip;
41  require LWP::UserAgent;  require LWP::UserAgent;
42  use HTML::PullParser;  use HTML::PullParser;
43    
44    # $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
45    # see "perldoc -f localtime"
46    use POSIX qw(strftime);
47    
48    use Carp;
49    
50    
51  ########################################  ########################################
52    
# Line 48  sub stripSpaces { Line 59  sub stripSpaces {
59    return $text;    return $text;
60  }  }
61    
62    sub trim {
63      my $string = shift;
64      return stripSpaces($string);
65    }
66    
67  sub stripNewLines {  sub stripNewLines {
68    my $text = shift;    my $text = shift;
69    #print "text: $text", "\n";    #print "text: $text", "\n";
# Line 81  sub stripHtml { Line 97  sub stripHtml {
97    return $result;    return $result;
98  }  }
99    
100    sub array_getRelations {
101      my $a_ref = shift;
102      my $b_ref = shift;
103      my @a = @{$a_ref};
104      my @b = @{$b_ref};
105    
106      my @isect = my @diff = my @union = ();
107      my $e;
108      my %count;
109      
110      foreach $e (@a, @b) { $count{$e}++ }
111    
112      foreach $e (keys %count) {
113          push(@union, $e);
114          push @{ $count{$e} == 2 ? \@isect : \@diff }, $e;
115      }
116      
117      my $result = {
118        union => \@union,
119        isect => \@isect,
120        diff => \@diff,
121      };
122    
123    }
124    
125    sub array_getDifference {
126      my $res = array_getRelations(shift, shift);
127      return $res->{diff};
128    }
129    
130  1;  1;

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

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