On Oct 2, Gerard Robin said:

use warnings;
# use strict;

$foo = 26;
@foo = ("here's", "a", "list");

&testsub (*foo);
print ("The value of \$foo is now $foo\n");

sub testsub {
local  (*printarray) = @_;
foreach  $element ( @printarray) {
print ("$element\n");
}
$printarray = 61;
}

it gives the expected result.

Yes, but it's pretty esoteric code.  Why are you doing this?

I can't make this script work with "use strict", always perl complains ?

If you REALLY want to use package variables instead of lexicals, then you need to follow the instructions in the 'strict' documentation for declaring your global variables:

  use strict;
  our ($foo, @foo);

  $foo = ...;
  @foo = ...;

  testsub(*foo);

  sub testsub {
    our ($x, @x);
    *x = $_[0];
    $x++;
    push @x, 100;
  }

But this is really inadvisable. What is your motivation to do this kind of thing?

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to