Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Ispell did it in my code with a broken pipe, anyone got a clue?

by jonjacobmoon (Pilgrim)
on Feb 12, 2002 at 18:38 UTC ( [id://144945]=perlquestion: print w/replies, xml ) Need Help??

jonjacobmoon has asked for the wisdom of the Perl Monks concerning the following question:

Okay, I am using Text::Ispell and coming across what may be a bug, but I want to try the code, catch it, and handle it without quitting prematurely. Lovers and users hate it when you quit prematurely.

Anyway...... Here is my code (or at least part of it):

# add words to the dictionary, if desired by the user foreach (@misses) { # logging only, not adding any words to dictionary if option s +et unless ($opts{terse}) { unless ($noRepAdds{$_}) { print "Do you wish to add [ $_ ] to the directory [ y|n ]? + "; $add = <STDIN>; chomp($add); if ($add eq 'y') { add_word($_); if ($!) { # this does print print "ERROR: $!\n"; } save_dictionary(); print "adding word: $_\n"; $noRepAdds{$_}++; } } } }

When I run across a problem adding to the dictionary, I get an error reflected in $! and then when I go to add another word, the program quits with the following message:

Do you wish to add nis2002 to the directory? y adding word: nis2002 Do you wish to add nbsp to the directory? Invalid word "nis2002": The +character '2' may not appear at the middle of a word. y Broken pipe

First, off ispell on the command line has no problem with nis2002 nor should it according to the documentation, so my guess is the Text::Ispell has a bug in it, although I could not find it. Still, there has to be a way to try and catch this exception.

Any ideas would be most helpful, I have been struggling with this minor bug for three days with no end in sight.


I admit it, I am Paco.

Edit by tye to change PRE to CODE around long lines

Replies are listed 'Best First'.
Re: Ispell did it in my code with a broken pipe, anyone got a clue?
by chipmunk (Parson) on Feb 13, 2002 at 02:59 UTC
    I tried ispell on the command line, and did get an error for 'nis2002':
    % ispell -a @(#) International Ispell Version 3.1.20 10/10/95 @nis2002 Word 'nis2002' contains illegal characters
    Since this isn't the behavior you're getting, perhaps you have two versions of ispell installed. It could be that the one you get from the command line allows 'nis2002', but the one that Text::Ispell is wrapped around doesn't.

    One quick solution is to remove the numbers, and add just 'nis':

    % ispell -a @(#) International Ispell Version 3.1.20 10/10/95 nis2002 & nis 18 0: Dis, his, ins, is, n's, NBS, NFS, nib, nibs, NIH, nil, nip +, nips, nit, nix, NTIS, sis, vis @nis nis2002 *
    BTW, I noticed on CPAN that Text::Ispell has been replaced by Lingua::Ispell. I don't know if the new module will fix your problem, but it shouldn't hurt.
      Well, when I do a whereis I only get one version, but mine is linked to aspell and acccording to the documentation on ispell home page, nis2002 is valid.

      However, your output without the aspell connection might have revealed the clue. Text::Ispell apparently gets confused by the connection with aspell. I used Lingua::Ispell per your suggetion, and it worked. IT WORKED! Man, I feel stupid when the answer is that simple.

      Chipmunk gets major ++ in my book!


      I admit it, I am Paco.
Re: Ispell did it in my code with a broken pipe, anyone got a clue?
by Rhandom (Curate) on Feb 12, 2002 at 19:46 UTC
    This doesn't answer the question (but it might) - looking at the code, $_ is used clear down through the code and even across some sub routine calls. That takes a lot of faith that nobody else is manipulating $_. Even if it doesn't fix the problem I would suggest using a named value rather than $_. Example:
    Instead of:
    foreach (@misses)
    Use:
    foreach my $miss (@misses)


    my @a=qw(random brilliant braindead); print $a[rand(@a)];
Re: Ispell did it in my code with a broken pipe, anyone got a clue?
by theorbtwo (Prior) on Feb 12, 2002 at 20:44 UTC
      Its a thought, but I tried that. No dice. This is clearly coming from ispell via the module.


      I admit it, I am Paco.
Re: Ispell did it in my code with a broken pipe, anyone got a clue?
by little (Curate) on Feb 13, 2002 at 02:39 UTC
    Do you use any other modules? Especially some that handle @ARGV different from @ENV ? or do you in any place?

    Have a nice day
    All decision is left to your taste

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://144945]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found