Changeset 5269 for branches/Release01x00/MailerContrib/lib/Foswiki/Contrib/MailerContrib/CompatibilityHacks.pm
- Timestamp:
- 10/15/09 19:28:59 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x00/MailerContrib/lib/Foswiki/Contrib/MailerContrib/CompatibilityHacks.pm
r1340 r5269 4 4 package IteratorHack; 5 5 6 use strict; 7 6 8 sub new { 7 my ( $class, $list) = @_;8 my $this = bless( {list => $list, index => 0, next => undef }, $class);9 my ( $class, $list ) = @_; 10 my $this = bless( { list => $list, index => 0, next => undef }, $class ); 9 11 return $this; 10 12 } 11 13 12 14 sub hasNext { 13 my ( $this) = @_;15 my ($this) = @_; 14 16 return 1 if $this->{next}; 15 if ( $this->{index} < scalar(@{$this->{list}}) ) {16 $this->{next} = $this->{list}->[ $this->{index}++];17 if ( $this->{index} < scalar( @{ $this->{list} } ) ) { 18 $this->{next} = $this->{list}->[ $this->{index}++ ]; 17 19 return 1; 18 20 } … … 31 33 32 34 sub eachChangeSince { 33 my ( $web, $since) = @_;35 my ( $web, $since ) = @_; 34 36 35 37 my $changes; 36 if ( open(F, "<$Foswiki::cfg{DataDir}/$web/.changes")) {38 if ( open( F, '<', "$Foswiki::cfg{DataDir}/$web/.changes" ) ) { 37 39 local $/ = undef; 38 40 $changes = <F>; … … 44 46 my @changes = 45 47 map { 46 # Create a hash for this line 47 { topic => $_->[0], user => $_->[1], time => $_->[2], 48 revision => $_->[3], more => $_->[4] }; 48 49 # Create a hash for this line 50 { 51 topic => $_->[0], 52 user => $_->[1], 53 time => $_->[2], 54 revision => $_->[3], 55 more => $_->[4] 56 }; 49 57 } 50 grep { 51 # Filter on time 52 $_->[2] && $_->[2] >= $since 53 } 54 map { 55 # Split line into an array 56 my @row = split(/\t/, $_, 5); 57 \@row; 58 } 59 reverse split( /[\r\n]+/, $changes); 58 grep { 59 60 # Filter on time 61 $_->[2] && $_->[2] >= $since 62 } 63 map { 64 65 # Split line into an array 66 my @row = split( /\t/, $_, 5 ); 67 \@row; 68 } 69 reverse split( /[\r\n]+/, $changes ); 60 70 61 71 return new IteratorHack( \@changes );
Note: See TracChangeset
for help on using the changeset viewer.
