Net::Trackback - an object-oriented interface for developing


Net-Trackback documentation Contained in the Net-Trackback distribution.

Index


Code Index:


Net-Trackback documentation Contained in the Net-Trackback distribution.

# Copyright (c) 2003-2004 Timothy Appnel (cpan@timaoutloud.org)
# http://www.timaoutloud.org/
# This code is released under the Artistic License.
package Net::Trackback;
use strict;
use base qw( Class::ErrorHandler Exporter );

use vars qw( @EXPORT_OK );
@EXPORT_OK = qw( encode_xml decode_xml );

use vars qw($VERSION);
$VERSION = 1.01;

my %Map = ('&' => '&amp;', '"' => '&quot;', '<' => '&lt;', '>' => '&gt;',
           '\'' => '&apos;');
my %Map_Decode = reverse %Map;
$Map{'\''}='&#39;';
my $RE = join '|', keys %Map;
my $RE_D = join '|', keys %Map_Decode;

sub encode_xml {
    return unless $_[1];
    (my $str = $_[1]) =~ s!($RE)!$Map{$1}!g;
    $str;
}

sub decode_xml {
    return unless $_[1];
    (my $str = $_[1]) =~ s!($RE_D)!$Map_Decode{$1}!g;
    $str;
}


#--- deprecated
sub is_message { ref($_[1]) eq 'Net::Trackback::Message' }
sub is_ping { ref($_[1]) eq 'Net::Trackback::Ping' }
sub is_data { ref($_[1]) eq 'Net::Trackback::Data' }

1;

__END__