Subject: | Module corrupts main::$_ |
If Conditionals such as if ( m/.../ ) break when main::$_ is changed by the module. Automated Babelfish service at Altavista is not working well. Google service is great, but has a smaller set of conversions.
------------------
Hello Dan,
First let me tell you that I have a patch file attached.
I've used your module before, but things have changed, and my application is different today, then what it was back when.
Now let me explain that I had a miserable time with the module, for two very different reasons.
First the module was corrupting the main package space, specifically $_, and my if conditionals using $_ were failing to match up, when I new that they should have matched.
Second the Babelfish server, at Altavista, sucks at best!
I switched to Google and got very good (robust) performance out of the module, with my modifications.
I hope that these changes will take you to beta.
I'll also submit a bug report.
Eric
--
Eric R. Meyers
Systems Engineer
GPG: 0x83CE80A3
http://users.adelphia.net/~ermeyers
--- /usr/lib/perl5/site_perl/5.8.6/WWW/Babelfish.pm 2003-10-19 00:33:55.000000000 -0400
+++ WWW/Babelfish.pm 2005-07-30 23:17:27.000000000 -0400
@@ -156,7 +156,10 @@
my ($self, %params) = @_;
# Paragraph separator is "\n\n" by default
- $/ = $params{delimiter} || "\n\n";
+ local $/ = $params{delimiter} || "\n\n";
+ local $_;
+
+ $params{delimiter} = "\n\n" if ( ! defined( $params{delimiter} ) );
undef $self->{error};
unless( exists($self->{Langs}->{$params{source}}) ){
@@ -214,7 +217,7 @@
if ($para =~ s/(^\s+)(\S)/$2/) {
$para_start_ws = $1 || "";
}
- chomp $para; # Remove the para delimiter
+ $para =~ s/$params{delimiter}//; # Remove the para delimiter
CHUNK:
foreach $chunk ( $self->_chunk_text($MAXCHUNK, $para) ) {
@@ -229,7 +232,13 @@
#$text = $self->_extract_text($res->as_string); #REMOVE
$text = &{ $Services->{ $self->{service} }->{extract_text} }($res->as_string);
- next RETRY if $text =~ /^\*\*time-out\*\*/; # in-band signalling; yuck
+ if ( ( ! defined( $text ) ) ||
+ ( $text =~ /^\*\*time-out\*\*/ )
+ ) # in-band signalling; yuck
+ {
+ next RETRY;
+
+ } ## end if
$text =~ s/\n$//; # Babelfish likes to append newlines
$transpara .= $text;