| 1 | #!perl | ||
| 2 | |||
| 3 | # ########################################################################## # | ||
| 4 | # Title: Trim trailing spaces transformer | ||
| 5 | # Creation date: 2007-03-05 | ||
| 6 | # Author: Michael Zedeler | ||
| 7 | # Description: Removes trailing spaces from all values | ||
| 8 | # Data Stream class | ||
| 9 | # Data transformer | ||
| 10 | # File: $Source: /data/cvs/lib/DSlib/lib/DS/Transformer/Rtrim.pm,v $ | ||
| 11 | # Repository: kronhjorten | ||
| 12 | # State: $State: Exp $ | ||
| 13 | # Documentation: inline | ||
| 14 | # Recepient: - | ||
| 15 | # ########################################################################## # | ||
| 16 | |||
| 17 | package DS::Transformer::Rtrim; | ||
| 18 | |||
| 19 | use base qw{ DS::Transformer }; | ||
| 20 | |||
| 21 | use strict; | ||
| 22 | use Carp::Assert; | ||
| 23 | |||
| 24 | our ($VERSION) = $DS::VERSION; | ||
| 25 | our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/; | ||
| 26 | |||
| 27 | |||
| 28 | sub process { | ||
| 29 | my( $self, $row ) = @_; | ||
| 30 | |||
| 31 | foreach my $field (keys %$row) { | ||
| 32 | $row->{$field} =~ s/^(.*\S+)?\s*$/$1/o; | ||
| 33 | $row->{$field} = '' unless defined $row->{$field}; | ||
| 34 | } | ||
| 35 | |||
| 36 | return $row; | ||
| 37 | } | ||
| 38 | |||
| 39 | 1; | ||
| 40 | |||
| 41 |