PriNet has asked for the wisdom of the Perl Monks concerning the following question:

I've checked several resources (including Perlmonks) and have an issue,
I have setup/installed (using CPAN) the module and implemented:
use Tie::Dir qw(DIR_UNLINK);
but every time I try to use:
tie %Directory, Tie::Dir, ".", DIR_UNLINK;
I get:
"Bareword Tie::Dir not allowed while strict subs in use..."
Any Ideas?

I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...

Replies are listed 'Best First'.
Re: Using Tie::Dir
by stevieb (Canon) on Aug 25, 2017 at 18:28 UTC

    Quote the bareword:

    tie %Directory, 'Tie::Dir', '.', DIR_UNLINK; # ^ ^
      Go figure, besides me feeling stupid and missing that, the documentation doesn't mention that *lol*
      thanks stevie...

      I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...

        Perfectly acceptable. ++ for using strict.

        Note that the distribution's last release was 1996, and I don't even know if strict was available back then (I'm not in a good position to look up when it was added). I didn't come onto the scene until 2001. strict likely wasn't in widespread use back then if it was available, and without strict (subs), barewords are legal.

        "... the documentation doesn't mention that ..."

        Tie::Dir is over 21 years old (latest release [v1.02]: 26 Apr 1996). There's quite a few things that its documentation tells you, or omits to tell you, that you should probably change (beyond the bareword issue you've already encountered).

        You appear to be using strict, which is very good: keep doing that. You should use lexical variables, that aren't shown in the documentation, or strict will complain about that.

        In addition, wherever it shows code like:

        new Tie::Dir arg1, ...;

        You should change that to:

        Tie::Dir::->new(arg1, ...);

        See "perlobj: Invoking Class Methods" for a discussion of why you should do this.

        — Ken