in reply to Re: Doesn't work in Cygwin
in thread Doesn't work in Cygwin

To the OP: I agree with berntB, the opinionated way Cygwin deals with line endings could really mess things up. If chomp doesn't work, you can always call
tr/\r\n//d
to completely get rid of LF and CR characters.

Furthermore, you check for duplicates with

if ($list_to_match =~ /$randomized_entry/)
which is an extremely poor ways to handle this kind of things. It won't match if unexpectedly $randomized_entry contains meta characters, it's prone to crashes if it doesn't actually look like a valid regexp, and it'll give you false positives when for example $randomized_entry contains "foo", and $list_to_match contains "if music be the food of love".

Replies are listed 'Best First'.
Re^3: Doesn't work in Cygwin
by maybeD (Sexton) on Nov 16, 2005 at 12:58 UTC
    Do you have a suggestion how you would handle the matching procedure here? The randomized lists consist of a particular type of string (a reference ID) and these same kinds of strings are in the list to match array elements.
    The latter case you describe cannot happen with these, but I guess some meta-characters might conceivably be able to feature in the reference IDs.

    Would you suggest using \Q?

      It depends on what you really want. If you just want to test for equality, I'd use eq. If you want to test if a string is a substring of another string, I'd use index. I'd only use regular expressions only as a very last resort, when indeed you need more power in functionality than offered by the above, such as wildcarding (in which case, use "." instead of "?" and ".*" instead of "*").

      Yes, in the latter case, quotemeta could have its uses.