hi, i already used the Exporter but still my prog cant access the arra +y in the module. Here is my module : package Voucher; use strict; use warnings; require Exporter; our @ISA = qw /Exporter/; our @EXPORT_OK = qw /@LIST @RANGE1 @RANGE2 @RANGE3 @RANGE4 @RANGE5 @RA +NGE6/; sub new { my ($class) = @_; my $self = { _loadSch => undef, _loadRanges => undef }; bless $self,$class; return $self; } sub loadSch { my ($self,$loadSch) = @_; my $schdir="./D_sch_folder/"; opendir(SCH,$schdir) || die "Error::Cannot load Sch Directory!!!\n +"; my @sch=grep(/[dD]_[sS][cC][hH].txt/,readdir(SCH)); my $schlist = $schdir.$sch[0]; open (IN,"$schlist") || die "Error::Cannot open Sch list!!!\n"; print "Loading d_sch.txt . . .\n\n"; our @LIST=<IN>; my $c=@LIST; print "$c\n"; sleep 1; } sub loadRanges { my ($self,$loadRanges) = @_; my $rangedir = "./number ranges/"; my $loadCTU7 = $rangedir."CTU7_range.txt"; my $loadTU7 = $rangedir."TU7_range.txt"; my $loadCTU30= $rangedir."CTU30_range.txt"; my $loadTU30 = $rangedir."TU30_range.txt"; my $loadDIAZ = $rangedir."DIAZ_ranges.txt"; my $loadIDD = $rangedir."IDD_range.txt"; open(R1,"$loadCTU7") || die "Error::Cannot load CTU7 ranges!!!\n"; open(R2,"$loadTU7") || die "Error::Cannot load TU7 ranges !!!\n"; open(R3,"$loadCTU30") || die "Error::Cannot load CTU30 ranges!!!\n +"; open(R4,"$loadTU30") || die "Error::Cannot load TU30 ranges!!!\n"; open(R5,"$loadDIAZ") || die "Error::Cannot load DIAZ ranges!!!\n"; open(R6,"$loadIDD") || die "Error::Cannot load IDD ranges!!!\n"; print "Loading E-Mongolia Card Ranges . . .\n\n"; my @RANGE1=<R1>; my @RANGE2=<R2>; my @RANGE3=<R3>; my @RANGE4=<R4>; my @RANGE5=<R5>; my @RANGE6=<R6>; sleep 1; } 1; <br> and here is my code: #! /usr/perl/bin/perl use warnings; use lib qw (./modules); use Voucher; $vouch=Voucher->new(); $vouch->loadSch(); # load d_sch.txt $vouch->loadRanges(); # load ranges $count=$pro1=$pro2=$pro3=$pro5=$pro6=$pro7=$pro8=$pro19=$pro20=$pro21= +$pro22=$pro23=$pro24=$pro25=$pro27=0; $l=@LIST; print "$l\n"; foreach $in (@LIST){ if ($in=~/^922/){ chomp($in); print "$in\n"; @a=split(/\s+/,$in); if ($a[4] eq "PROFILE1"){ $pro1++; $count++; } elsif ($a[4] eq "PROFILE2"){ $pro2++; $count++; } elsif ($a[4] eq "PROFILE3"){ $pro3++; $count++; } elsif ($a[4] eq "PROFILE5"){ $pro5++; $count++; } elsif ($a[4] eq "PROFILE6"){ $pro6++; $count++; } elsif ($a[4] eq "PROFILE7"){ $pro7++; $count++; } elsif ($a[4] eq "PROFILE8"){ $pro8++; $count++; } elsif ($a[4] eq "PROFILE19"){ $pro19++; $count++; } elsif ($a[4] eq "PROFILE20"){ $pro20++; $count++; } elsif ($a[4] eq "PROFILE21"){ $pro21++; $count++; } elsif ($a[4] eq "PROFILE22"){ $pro22++; $count++; } elsif ($a[4] eq "PROFILE23"){ $pro23++; $count++; } elsif ($a[4] eq "PROFILE24"){ $pro24++; $count++; } elsif ($a[4] eq "PROFILE25"){ $pro25++; $count++; } elsif ($a[4] eq "PROFILE27"){ $pro27++; $count++; } } } print "$count\n";

In reply to Re^2: how to import a module var by rianne809
in thread how to import a module var by rianne809

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.