Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Your code could be compacted quite a bit, if you change the calling syntax slightly and rely on the while () construct - and the surrounding perl magic :)

    Something like the following

    if (@ARGV < 1) {
        die "usage: fog -|FILE1 ...|-s STRING\n"

    my $fog_index = new Lingua::EN::Fathom;

    if ($ARGV[0] =~ /^-s$/) {
        # string argument
        $fog_index->analyse_block($ARGV[1], 1);
        print $fog_index->report, "\n";

    local $/; # slurp whole files

    • Just curious--what was it in the diction/style package that you wanted to improve?
      • Well, there were a couple of points, some of them are probably a matter of personal taste/preferences ...

        • Consistency - I wanted to stick to Mark's command line arguments and allow the string argument. Personally I would have chosen a "clean" 'while ()' type of interface, meaning if I wanted to know the fog index of a string, I would pass it in via the shell with echo "string" | fog. This way the script behaves like a normal unix command line tool in that it can work as a filter for piping or be used to wo