Hello,

I which to use eval to execute subroutines dynamically.

The following code snippet fails:


#!/usr/bin/perl

use strict;
use warnings;

sub asub {
  our $abc;
  print $abc;
}

my $abc = "abc\n";
eval "asub";
exit 0;


with the error:

Use of uninitialized value in print at ...

asub should see the $abc variable in the main program, but doesn't.
How do I make asub reference variables in the main program?

/Anders



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to