in reply to Re: glob with special characters
in thread glob with special characters

I suspect a subtlety (bug?) in Text::ParseWords or its usage.

The documentation of this module is quite explicit about how it works:

The $keep argument is a boolean flag. If true, then the tokens are split on the specified delimiter, but all other characters (quotes, backslashes, etc.) are kept in the tokens. If $keep is false then the &*quotewords() functions remove all quotes and backslashes that are not themselves backslash-escaped or inside of single quotes (i.e., "ewords() tries to interpret these characters just like the Bourne shell).

The *quotewords functions all call parse_line, which is the one that performs the real job. File::Glob calls parse_line with a $keep argument of 0:

if ($pat =~ /\s/) { # XXX this is needed for compatibility with the csh # implementation in Perl. Need to support a flag # to disable this behavior. require Text::ParseWords; @pat = Text::ParseWords::parse_line('\s+',0,$pat); }

So, knowing this, it comes as no surprise that some backslashes are being eaten. As soon as I replace the 0 with a 1, the behaviour of glob begins to match my expectations. What bothers me is that File::Glob is one of that pieces of software so widely used that it's impossible that this little humble programmer have found a bug in it :^).

--
David Serrano

Replies are listed 'Best First'.
Re^3: glob with special characters
by shmem (Chancellor) on Oct 06, 2006 at 21:44 UTC
    Hue-Bond++

    will you file a bug report on this?

    abrazo,
    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
    400th post

      Yes, I would be glad about it, and with perlbug it shouldn't be difficult to do it right on the first try. Right now I'm investigating some problems with backslashes in filenames, although I think this is a completely separate issue that should be brought up separately. (Update: Bah! somehow File/Glob.pm had returned to its unchanged status).

      Thank you for updating your answer; at the beginning I didn't understand if you were acknowledging the bug or what :^).

      --
      David Serrano, being nearer to become a Perl hacker