in reply to Win32::File::SetAttributes not numeric?

Sorry to bother all... but after hours of looking at this I finally figured it out, although I don't completely understand the reason.

I simply moved the use Win32::File; line from the top of my code to the subroutine in which it was used.

Thanks!

Replies are listed 'Best First'.
Re^2: Win32::File::SetAttributes not numeric?
by ikegami (Patriarch) on Jun 05, 2009 at 19:42 UTC

    Bad fix. The use needs to be in the same package, but it putting in the sub looses readability and maintainability points.

    By the way, use use strict; use warnings;!!

      I am currently using the pragmas use strict; use warnings; use diagnostics;

      I'd much prefer to keep the use Win32::File;at the top of the package, but apparently my module doesn't like that.

      The subroutine contains the following:

      my $setROattr = READONLY; my $unsetROattr = ~READONLY; # set file attributes to allow editing Win32::File::SetAttributes($file, $unsetROattr);
      .. and the error with use Win32::File; at the top of the package is still...
      Argument "READONLY" isn't numeric in subroutine entry
      Thanks for the help!

        I am currently using the pragmas use strict; use warnings; use diagnostics;

        You only think you are. Just like use Win32::File; isn't working, neither is use strict;.

        $ perl -e'use strict; my $attr; $attr |= READONLY' Bareword "READONLY" not allowed while "strict subs" in use at -e line +1. Execution of -e aborted due to compilation errors.

        Without use strict;, READONLY would be considered the same as "READONLY", which is the symptom you described.

        You still don't show us your code. Post the first 10 or 20 lines of your module's source code. If you can't, for some legal reasons, make sure they look like this:

        package Your::Package; use strict; use warnings; use Win32::File;

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)