|
our $VERSION = '0.32' ;
our @EXPORT_OK = qw< STARTER TERMINATOR escape unescape transfer > ;
our @EXPORT = ();
our %EXPORT_TAGS = (
all => \ @EXPORT_OK ,
escaping => [ qw< escape unescape > ],
constants => [ qw< STARTER TERMINATOR > ],
);
use constant STARTER => "Data::Embed/index/begin\n" ; use constant TERMINATOR => "Data::Embed/index/end\n" ; sub escape {
my $text = shift ;
$text =~ s{([^\w.-])}{ '%' . sprintf ( '%02x' , ord $1)}egmxs;
return $text ;
}
sub unescape {
my $text = shift ;
$text =~ s{%(..)}{ chr ( hex ($1))}egmxs;
return $text ;
}
sub transfer {
my ( $infh , $outfh ) = @_ ;
while ( 'necessary' ) {
my $buffer ;
my $n = sysread $infh , $buffer , 0, 4096;
LOGCROAK "sysread(): $OS_ERROR" unless defined $n ;
last unless $n ;
print { $outfh } $buffer ;
}
return ;
}
1;
|