Re: Include variables from external perl script



On Oct 30, 1:51 pm, nobul...@xxxxxxxxx (Nobul...@xxxxxxxxx) wrote:
On Oct 30, 2:50 pm, mri...@xxxxxxxxx (Paul Lalli) wrote:

If there is no strict, 'our' is a no-op.

Not entirely true. The scope of a variable declared with our is
different from one that's not needed to be declared because use strict
is not in use.

My, that's some mighty fine crow! YUUUUUMMMY!

My bad....

Yes, 'our' spans package boundaries, which makes it not a no-op, just
as Nobull said:

$ perl -lwe'
package Foo;
$baz = "hello world";
print $baz;
package Bar;
print $baz;
'
Name "Bar::baz" used only once: possible typo at -e line 6.
hello world
Use of uninitialized value in print at -e line 6.


Compared to:
$ perl -lwe'
package Foo;
our $baz = "hello world";
print $baz;
package Bar;
print $baz;
'
hello world
hello world


I stand suitably humbled, chagrined, and better informed.

Paul Lalli

.



Relevant Pages

  • Re: question about "package" and variable scope...
    ... An "our" declaration declares a global variable that will be ... The package in which the variable is entered is ...
    (comp.lang.perl.misc)
  • Generic and visibility...
    ... package Bar is ... package Baz is ... task type Dummy is ...
    (comp.lang.ada)
  • Re: advice on package design
    ... > I've written a package for linked list operations for my personal use. ... > After a while I figured I'd write another package for some string ... package Foo is ... then of course you can "use" Baz referencing it as Foo.Baz everywhere Foo ...
    (comp.lang.ada)
  • Re: how to avoid interning local var names
    ... CL-USER> (defun foo (baz) baz) ... I would not mind if BAZ was not interned. ... and it clashed with some package I use-package'd _after_ I ...
    (comp.lang.lisp)
  • Re: "reexporting" symbols
    ... and package B which uses package A's symbols, its defpackage looks ... (:export baz)) ... But to take advantage of the full functionality of:b, ...
    (comp.lang.lisp)