Hi Monks -

I wrote a simple script that allows the user to enter a pattern of letters, searches through a list of words in a file, and outputs any words that match the pattern (sort of like a crossword solver). Here's the code:

#!/usr/bin/perl use strict; print "Enter word to be solved.\n"; print "Use a dash (-) to indicate a single missing letter.\n"; print "Use a star (*) to match 0 or more letters.\n"; print "Use a plus (+) to match 1 or more letters.\n"; print " WORD --> "; chomp( my $word = <STDIN> ); $word =~ s/\-/\\w/g; $word =~ s/\*/\\w*/g; $word =~ s/\+/\\w+/g; open WORDLIST, "< WORD.LST" || die "Cannot open WORD.LST: $!\n"; while (<WORDLIST>) { chomp( my $newWord = $_ ); if ( $newWord =~ m/^$word$/i ) { print $newWord . "\n"; } } close WORDLIST;

When I run the script on Windows (ActiveState Perl), it seems to work perfectly. However, when I run it under Cygwin I get no results, no matter what pattern I enter - even if I type the exact word.

My concern isn't as frivolous as it seems. I'm developing a much larger script for work that uses a good bit of RegEx pattern matching. It will eventually run on a Unix server, but I'm running it through Cygwin for alpha testing. I need to be sure I'm getting accurate results before I muck up the data on our dev servers.

So - am I missing something painfully obvious, or has anyone else noticed any issues with Perl on Cygwin?


In reply to Pattern Matching in Cygwin Perl vs. Win32 Perl by InsolentFlunkey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.