perl error in spamassassin

2008-02-03 Thread totalmanwhore
Hi,
 I am running a Centos 4.6 box, with perl 5.8.8 and Plesk 8.3,
Spamassasin was running fine until i upgraded  some perl modules, now
i get the following error when i try and start spamassassin


Can't locate object method "register_domain" via package
"IO::Socket::INET" at /usr/lib/perl5/5.8.8/IO/Socket/INET.pm line 22.
Compilation failed in require at /usr/bin/spamd line 44.
BEGIN failed--compilation aborted at /usr/bin/spamd line 79.
Starting psa-spamassassin service:  [FAILED]

I really dont want to rip out the perl willy nilly and start from
scratch  for fear of  causing more  to break, any suggestions?
 ta
 will


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: perl error in spamassassin

2008-02-03 Thread Chas. Owens
On Feb 3, 2008 5:24 AM,  <[EMAIL PROTECTED]> wrote:
> Hi,
>  I am running a Centos 4.6 box, with perl 5.8.8 and Plesk 8.3,
> Spamassasin was running fine until i upgraded  some perl modules, now
> i get the following error when i try and start spamassassin
>
>
> Can't locate object method "register_domain" via package
> "IO::Socket::INET" at /usr/lib/perl5/5.8.8/IO/Socket/INET.pm line 22.
> Compilation failed in require at /usr/bin/spamd line 44.
> BEGIN failed--compilation aborted at /usr/bin/spamd line 79.
> Starting psa-spamassassin service:  [FAILED]
>
> I really dont want to rip out the perl willy nilly and start from
> scratch  for fear of  causing more  to break, any suggestions?
>  ta
>  will
snip

First, a few questions:
1. How did you go about trying to upgrade the Perl modules?
2. Did you get any warnings or error messages while upgrading?
3. Which Perl modules did you upgrade?
4. What is the output of perl -MIO::Socket -le 'print
$IO::Socket::INET::VERSION'
5. What is the output of perl -MIO::Socket -le 'print $IO::Socket::VERSION'

IO::Socket defines register_domain and IO::Socket::INET is supposed to
have IO::Socket in its @ISA array, so the fact that you are getting
this error means there is something terribly wrong with the installs
you did.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Newbie: Has anyone used Tie::Hash::TwoWay

2008-02-03 Thread axtens
On Feb 1, 10:00 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> axtenswrote:
> > G'day everyone

Thanks for that. I did, however, give up on using TwoWay and used an
idea a colleague had given me, as below:

sub Misspellings_Setup {
  @wordsList = split /\n/, <<'__WORDLIST__'
abandonned  abandoned
aberation   aberration
abilities   abilties
.
.
.
__WORDLIST__
;

  foreach (@wordsList) {
($left, $right) = split /\t/, $_;
@leftList = split /,\s* /, $left;
@rightList = split /,\s*/, $right;
foreach $l (@leftList) {
  foreach $r (@rightList) {
  if ( exists $misDict{"!-$l"} ) { $misDict{"!-$l"} .= $r . "^"; }
else { $misDict{"!-$l"} = $r . "^"; }
  if ( exists $misDict{"?-$r"} ) { $misDict{"?-$r"} .= $l . "^"; }
else { $misDict{"?-$r"} = $l . "^"; }
  }
}
  }
}

misDict is an "our" declared elswhere. Getting something out of the
hash is as below.

sub Misspellings_Suggest {
#receives string
#returns string
my $res;
my $string = shift;
if ( ! %misDict ) {
Misspellings_Setup();
}
if ( exists( $misDict{"!-$string"} ) ) {
$res = $misDict{"!-$string"};
} else {
$res = $string;
}
$res =~ s/\^/FS/ge;
return $res;
}

Kind regards,
Bruce.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Regular expression for extracting hrefs from HTML file

2008-02-03 Thread R (Chandra) Chandrasekhar

Dear Folks,

I am trying to construct a regular expression to extract strings having the 
structure


http://...";>

from HTML files, as part of learning regexes. I have used the script below to do 
this:

--
#!/usr/bin/perl
use warnings;
use diagnostics;
use strict;

# Detect and print out all instances of
# http://..";>
# in any file that is input

my ($fh, $file);

# Optionally slurp the file as a paragraphs or as a single record
# $/ = "";
# $/ = undef;

while (@ARGV)
   {
   $file = shift;
open $fh, '<', $file or die "Cannot open $file: $!\n";
while (<$fh>)
{
if (m|(http://.*?";>)|sg) {print "$1\n";}
}
close $fh;
}
print "Finished\n";
--

It seems to work OK on most links in the files I have tried out, but not on one 
particular href in a valid HTML file, which I have extracted below:

--
Retrieved 29 June 2006 from http://www.oxfordreference.com/views/ENTRY.html?subview=Main&entry=t124.e024%
0">
  
http://www.oxfordreference.com/views/ENTRY.html?subview=Main&entry=t124.e024%
0
--
(The HTML file from which this fragment was extracted, was converted 
automatically from LaTeX to HTML, and passes HTML 4.0 transitional syntax. It 
also renders correctly on a browser).


The octal dump for this input file is:
--
000   R   e   t   r   i   e   v   e   d   2   9   J   u   n
020   e   2   0   0   6   f   r   o   m   <   t   t   >
040   <   a   h   r   e   f   =   "  \n   h   t   t   p
060   :   /   /   w   w   w   .   o   x   f   o   r   d   r   e   f
100   e   r   e   n   c   e   .   c   o   m   /   v   i   e   w   s
120   /   E   N   T   R   Y   .   h   t   m   l   ?   s   u   b   v
140   i   e   w   =   M   a   i   n   &   e   n   t   r   y   =   t
160   1   2   4   .   e   0   2   4   %  \n   0   "   >  \n
200   h   t   t   p   :   /   /   w   w   w   .   o   x   f   o   r
220   d   r   e   f   e   r   e   n   c   e   .   c   o   m   /   v
240   i   e   w   s   /   E   N   T   R   Y   .   h   t   m   l   ?
260   s   u   b   v   i   e   w   =   M   a   i   n   &   a   m   p
300   ;   e   n   t   r   y   =   t   1   2   4   .   e   0   2   4
320   %  \n   0   <   /   a   >   <   /   t   t   >
334
--

Can someone please tell me what I have done wrong and what I must do to extract 
the above href automatically?


Many thanks in advance.

Chandra
03 Feb 08

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Regular expression for extracting hrefs from HTML file

2008-02-03 Thread Chas. Owens
On Feb 3, 2008 8:50 AM, R (Chandra) Chandrasekhar <[EMAIL PROTECTED]> wrote:
> Dear Folks,
>
> I am trying to construct a regular expression to extract strings having the
> structure
>
> http://...";>
>
> from HTML files, as part of learning regexes. I have used the script below to 
> do
> this:
snip

Part of learning to use regexes is learning when not to use them.
This is a job for an HTML parser, not a single regex.  Offhand, I
would say that your problem is that the anchor tag is spread across
more than one line and your script appears to be reading the file one
line at a time.  This is but one corner case you will have to deal
with (which is why you should use a parser instead).

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp not working past one character

2008-02-03 Thread Chas. Owens
On Feb 3, 2008 12:07 PM,  <[EMAIL PROTECTED]> wrote:
> On Feb 2, 11:10 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> > [EMAIL PROTECTED] wrote:
> > > I have a program with a line like
> >
> > > while () {
> > >  if (/stuff/i) {
> > >   print;
> > >  }
> > > }
> >
> > > When I run the program, and I replace "stuff" with only one character,
> > > like "d", it works exactly as I expect. But if instead of using "d", I
> > > use "da" or "date" (which I know are in FILE, because it's a text file
> > > I made) nothing prints on the screen. I've also tried to have it print
> > > to another file, and that's turned out blank too.
> >
> > > What am I doing wrong?
> >
> > My guess would be that you are creating a UTF-16LE text file on Windows
> > and trying to read it on your Mac?
> >
> > John
> > --
> > Perl isn't a toolbox, but a small machine shop where you
> > can special-order certain sorts of tools at low cost and
> > in short order.-- Larry Wall
>
> John,
>
> I am using a Mac. I don't know what kind of Text file it is, because
> it's being created by Automator as a scrape of a website. If the
> encoding is the problem, how do I work that?
>
> Yes, I realize that the problem I'm describing is really weird and the
> code I posted should work perfectly. So it's probably not my coding
> but something to do with the system I'm on (OS X 10.4.11) or the file
> I'm working with (a .txt).
snip

Eextensions don't matter in UNIX (and OS X is a UNIX).  Step one to
determining what a file contains is running the file command against
it like this:

file foo.txt

This will give you a better idea what you are working with.  The next
step is looking at header of the HTML, it will probably tell you
exactly what encoding is being used.  It should look something like
this:



In that case the file is encoded with UTF-8.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp not working past one character

2008-02-03 Thread PlagueMagazine
On Feb 2, 11:10 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> [EMAIL PROTECTED] wrote:
> > I have a program with a line like
>
> > while () {
> >  if (/stuff/i) {
> >   print;
> >  }
> > }
>
> > When I run the program, and I replace "stuff" with only one character,
> > like "d", it works exactly as I expect. But if instead of using "d", I
> > use "da" or "date" (which I know are in FILE, because it's a text file
> > I made) nothing prints on the screen. I've also tried to have it print
> > to another file, and that's turned out blank too.
>
> > What am I doing wrong?
>
> My guess would be that you are creating a UTF-16LE text file on Windows
> and trying to read it on your Mac?
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order.-- Larry Wall

John,

I am using a Mac. I don't know what kind of Text file it is, because
it's being created by Automator as a scrape of a website. If the
encoding is the problem, how do I work that?

Yes, I realize that the problem I'm describing is really weird and the
code I posted should work perfectly. So it's probably not my coding
but something to do with the system I'm on (OS X 10.4.11) or the file
I'm working with (a .txt).


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Regular expression for extracting hrefs from HTML file

2008-02-03 Thread Gunnar Hjalmarsson

R (Chandra) Chandrasekhar wrote:

Dear Folks,

I am trying to construct a regular expression to extract strings having 
the structure


http://...";>

from HTML files, as part of learning regexes. I have used the script 
below to do this:

--
#!/usr/bin/perl
use warnings;
use diagnostics;
use strict;

# Detect and print out all instances of
# http://..";>
# in any file that is input

my ($fh, $file);

# Optionally slurp the file as a paragraphs or as a single record
# $/ = "";
# $/ = undef;

while (@ARGV)
   {
   $file = shift;
open $fh, '<', $file or die "Cannot open $file: $!\n";
while (<$fh>)
{
if (m|(http://.*?";>)|sg) {print "$1\n";}
}
close $fh;
}
print "Finished\n";
--

It seems to work OK on most links in the files I have tried out, but not 
on one particular href in a valid HTML file, which I have extracted below:

--
Retrieved 29 June 2006 from http://www.oxfordreference.com/views/ENTRY.html?subview=Main&entry=t124.e024% 
0">


You are examining one line at a time, while that string spans over 
multiple lines.


Can someone please tell me what I have done wrong and what I must do to 
extract the above href automatically?


Slurp respective file into a scalar variable:

  {
local $/;
my $content = <$fh>;
print "$1\n" while $content =~ m|(http://.*?";>)|gis;
  }

(I also added the /i modifier.)

Furthermore, please read the FAQ entry "perldoc -q URL".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Newbie: Has anyone used Tie::Hash::TwoWay

2008-02-03 Thread John W. Krahn

axtens wrote:

On Feb 1, 10:00 am, [EMAIL PROTECTED] (Rob Dixon) wrote:

axtenswrote:

G'day everyone


Thanks for that. I did, however, give up on using TwoWay and used an
idea a colleague had given me, as below:

sub Misspellings_Setup {
  @wordsList = split /\n/, <<'__WORDLIST__'
abandonned  abandoned
aberation   aberration
abilities   abilties
.
.
.
__WORDLIST__
;


Why not just create @wordsList as an AoA so you don't have to do all 
that splitting:


my @wordsList = (
[ 'abandonned', 'abandoned' ],
[ 'aberation',  'aberration' ],
[ 'abilities',  'abilties' ],
...
);



  foreach (@wordsList) {
($left, $right) = split /\t/, $_;
@leftList = split /,\s* /, $left;
@rightList = split /,\s*/, $right;


I didn't see any commas in your data so what is this supposed to be doing?



foreach $l (@leftList) {
  foreach $r (@rightList) {
  if ( exists $misDict{"!-$l"} ) { $misDict{"!-$l"} .= $r . "^"; }
else { $misDict{"!-$l"} = $r . "^"; }
  if ( exists $misDict{"?-$r"} ) { $misDict{"?-$r"} .= $l . "^"; }
else { $misDict{"?-$r"} = $l . "^"; }


You don't have to test for the key existence as perl will autovivify the 
values.




  }
}
  }
}

misDict is an "our" declared elswhere. Getting something out of the
hash is as below.

sub Misspellings_Suggest {
#receives string
#returns string
my $res;
my $string = shift;
if ( ! %misDict ) {
Misspellings_Setup();
}
if ( exists( $misDict{"!-$string"} ) ) {
$res = $misDict{"!-$string"};
} else {
$res = $string;
}
$res =~ s/\^/FS/ge;


The /e option evaluates the "FS" string as perl code but it is not perl 
code so why use the /e option?




return $res;
}



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/