Skip to content

Instantly share code, notes, and snippets.

@textarcana
Created March 18, 2021 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save textarcana/ec569a36cd29e4a64702a159dd91f90a to your computer and use it in GitHub Desktop.
Save textarcana/ec569a36cd29e4a64702a159dd91f90a to your computer and use it in GitHub Desktop.
Spell check a word on the command line.
#!/usr/bin/env perl -w
# Suggest alternate spellings for a word
use strict;
use Text::Aspell;
my $speller = Text::Aspell->new;
my $word = qq{$ARGV[0]};
my @suggestions_raw = $speller->suggest( $word );
my @suggestions = grep { $_ =~ /^\w+$/ } @suggestions_raw;
$speller->check( $word )
and exit(0)
or print join(qq{\n}, @suggestions)
and exit(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment