Then to try it in the Perl debgugger:package Foo; use strict; use Exporter 'import'; # Export on demand, so the caller knows # where these came from. our @EXPORT_OK = qw(get_array populate_array); { my @array; # can only be accessed in this block sub get_array { \@array } sub populate_array { @array = 'a' .. 'h' } } 1;
% perl -de0 Loading DB routines from perl5db.pl version 1.37 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(-e:1): 0 DB<1> use Foo qw(get_array populate_array) DB<2> x get_array() 0 ARRAY(0x7fa9ac81a298) empty array DB<3> populate_array() DB<4> x get_array() 0 ARRAY(0x7fa9ac81a298) 0 'a' 1 'b' 2 'c' 3 'd' 4 'e' 5 'f' 6 'g' 7 'h' DB<5>
In reply to Re: How we can link/access the variables of different module in main script without defining variable as global.. ??
by Arunbear
in thread How we can link/access the variables of different module in main script without defining variable as global.. ??
by pinkeshprajapati
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |