Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Just looking at it, I'd guess that it's a precedence issue and you need some parens thrown in. This is what I get from B::Deparse.

      % perl -MO=Deparse -MReadonly -e 'Readonly my $CurrentUser = $ENV{SUDO_USER} || getpwuid $>'
      Type of arg 1 to Readonly::Readonly must be one of [$@%] (not scalar assignment) at -e line 1, at EOF
      -e had compilation errors.
      use Readonly;
      &Readonly(my $CurrentUser = $ENV{'SUDO_USER'} || getpwuid $>);

    So, not what I expected, but still an

    • It's a context error. Consider the first line:

      my $CurrentUser = $ENV{SUDO_USER} || getpwuid $>;

      That must be scalar context (in fact, the || forces the left side to be in scalar context). However, consider the new version:

      Readonly my $CURRENT_USER => $ENV{SUDO_USER} || getpwuid $>;

      We have a list, not an assignment, so we have list context. getpwuid $> in list context generates more than one value and Readonly recognizes that we're trying to use a scalar, so it dies. The fix is to fo