in reply to Re: Hitting head against wall over Readonly compilation errors
in thread Hitting head against wall over Readonly compilation errors

A provisional test indicates that this works (a little more to do before I break out the port to celebrate). However I am still puzzled as to what is going on here. Is the Readonly module forcing the variables into the global space? Surely that would be something terrible.
  • Comment on Re^2: Hitting head against wall over Readonly compilation errors

Replies are listed 'Best First'.
Re^3: Hitting head against wall over Readonly compilation errors
by Anonymous Monk on Sep 12, 2009 at 13:37 UTC
    Is the Readonly module forcing the variables into the global space? Surely that would be something terrible.

    No. perldoc -f our 'our' is not 'my'

      Okay it's starting to make sense. The following does what I would expect:
      use Readonly; sub testvalue { Readonly my %hash => {h =>1}; return \%hash; } my $h = testvalue(); $h->{h} = 2;
Re^3: Hitting head against wall over Readonly compilation errors
by ikegami (Patriarch) on Sep 13, 2009 at 01:29 UTC

    Is the Readonly module forcing the variables into the global space? Surely that would be something terrible.

    There is no such thing. main:: could be considered the root namespace, but it's no more or less global than any other namespaces.

    Furthermore, Readonly doesn't move or create variables. It simply alters the variable you pass to it to make it readonly. If you pass it a variable in the main:: namespace, it'll affect a variable in the main:: namespace. If you pass it a variable in the Foo::Bar:: namespace, it'll affect a variable in the Foo::Bar:: namespace. It you pass it a lexical variable, it'll affect the lexical variable.

      Yes I understand what is going on now. Thanks to everyone for educating me in what "our" means. I really had not quite grasped it.