in reply to using require as c like #include?
# -- HoH.pl -- #!/usr/bin/perl -w use strict; use Data::Dumper; use hash; print Dumper($HoH); # refer to the imported variable # -- hash.pm -- package hash; our @EXPORT = '$HoH'; # export your variable $HoH use base "Exporter"; our $HoH = { 'HASH_1' => { item_a => "abc", item_b => "123", item_c => "blue", }, 'HASH_2' => { item_a => "xyz", item_b => "789", item_c => "white", }, 'HASH_3' => { item_a => "ijk", item_b => "3.14", item_c => "yellow", } }; 1;
# -- HoH.pl -- #!/usr/bin/perl -w use strict; use Data::Dumper; use hash; my $h = new hash; print Dumper($h->HoH); # -- hash.pm -- package hash; my $HoH = { 'HASH_1' => { item_a => "abc", item_b => "123", item_c => "blue", }, 'HASH_2' => { item_a => "xyz", item_b => "789", item_c => "white", }, 'HASH_3' => { item_a => "ijk", item_b => "3.14", item_c => "yellow", } }; sub new { my $class = shift; bless {}, $class; } sub HoH { # my $class = shift; $HoH # the HoH method returns hash reference } 1;
|
|---|