use one subroutine's variable value in another subroutine inside a module.
- From: king <hara.acharya@xxxxxxxxx>
- Date: 26 Apr 2007 06:28:03 -0700
I have a module named TPWizardMgr.pm as below.
========================================================================
package TPWizardMgr;
use strict;
use XML::DOM;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
# reset all data
$self->{load_school_template} = {};
$self->{get_course_info} = {};
# load school types from config file
$self->{load_school_template} = [];
$self->{get_course_info} = [];
return $self;
}
sub load_school_template
{
my $self = shift;
my $len ;
my $item;
my @years;
my $periods;
my $subject_name;
my @template_subject_period;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("/usr/local/apache2/wizard_data/
liceo_classico.xml");
foreach my $school_template($doc-
getElementsByTagName('subject-templates')){
$len = $school_template-
getElementsByTagName('subject-template')->getLength() ;@years =
('periods_1','periods_2','periods_3','periods_4','periods_5');
for(my $i = 0;$i<$len;$i++)
{
$item = $school_template-
getElementsByTagName('subject-template')->item($i);$subject_name = $item-
getAttribute('name');for my $count (0..4)
{
$periods = $item-
getAttribute($years[$count]);push
(@template_subject_period, [$subject_name,$years[$count], $periods]);
}
}
}
return @template_subject_period;
}
sub get_course_info
{
my $self = shift;
my $subject_name = shift;
my @years = shift;
my $periods = shift;
my $count = shift;
my @template_subject_period = shift;
print "Please enter period to get subject and number of
periods \n";
my $gotperiod = <>;
chomp($gotperiod);
for(my $i=0;$i <= $#template_subject_period;$i++)
{
print $#template_subject_period . "\n";
print "inside for loop\n";
if($template_subject_period[$i]->[1] eq $gotperiod)
{
push (@template_subject_period,
[$subject_name,$years[$count], $periods]);
print "Subject:\t" .
$template_subject_period[$i]->[0] . $template_subject_period[$i]-
[2] . "\n";}
}
return $self->{get_course_info};
}
1;
==================================================================
But I want to use the variable @template_subject_period in the
subroutine get_course_info( ).
I am not able to use this @template_subject_period variable value in
the get_course_info subroutine.
How I can do this.
Thanks in advance.
.
- Follow-Ups:
- Re: use one subroutine's variable value in another subroutine inside a module.
- From: Brian McCauley
- Re: use one subroutine's variable value in another subroutine inside a module.
- From: injunjoel
- Re: use one subroutine's variable value in another subroutine inside a module.
- From: Brian McCauley
- Re: use one subroutine's variable value in another subroutine inside a module.
- From: Glenn Jackman
- Re: use one subroutine's variable value in another subroutine inside a module.
- From: Mumia W.
- Re: use one subroutine's variable value in another subroutine inside a module.
- Prev by Date: Re: $ENV HOME on windows
- Next by Date: SQL statement in Perl doesn't work
- Previous by thread: Could not find ParserDetails.ini...
- Next by thread: Re: use one subroutine's variable value in another subroutine inside a module.
- Index(es):
Relevant Pages
|