in reply to Wildcards - open a file with one unknown digital character

By the way, escaping _ and - is unnecessary in string literals, in regex patterns and in glob patterns. Escaping them is just visually confusing.

Also, by simply appending : $! to your error message, you make it far more useful.

Replies are listed 'Best First'.
Re^2: Wildcards - open a file with one unknown digital character
by mypatek (Initiate) on Jan 11, 2010 at 20:12 UTC
    Thank you for the hints. I escaped _ because of the scalars containing _ in their names. if I use my @cachefiles = glob("/home/cache/*_$scalar_1_2"); it does not recognize $scalar_1 I'd have to write my @cachefiles = glob("/home/cache/*_$scalar_1\_2");
      "...${scalar}_..."
      would also do. The curly method also works where a slash wouldn't.
      "...${abc}def..."