Anders Hartman:
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;


I don't think you want an eval here.

use strict;
use warnings;

our $abc = "abc\n";

sub asub {
  print $abc;
}

asub;


Also you may want to know something about Perl's variable scope, see:
http://perl.plover.com/FAQs/Namespaces.html.en

--
Jeff Pang
http://home.arcor.de/pangj/

--
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