Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with accessing PM file 1

Status
Not open for further replies.

calabama

Programmer
Feb 19, 2001
180
0
0
US
Greetings to all,
I am having a problem when accessing the data from a PM file. Unless I actually put a value into the scalar there is NO data.
I have used require before with no problems . I dont understand what I have done that could break it.

Anyway this is what the print statement says. $smonth is ,$sday is 2, $syear is 2000
I was hoping that $smonth value would be "Jun" not "". Thanks for any help

Tim
Code:
#!/usr/local/bin/perl -w
use strict;
use diagnostics;
use CGI qw(:standard);
print header();

require schedule;


my $s_month;
my $s_day = 2 ;
my $s_year = 2000;

print "\$smonth is $s_month ,\$sday is $s_day, \$syear is $s_year\n";


################### PM FILE #########################

#schedule

$s_month = 'Jun'; 
$s_day = '21'; 
$s_year ='2004'; 

$week_1 = 'TEAM 1'; 
$week_2 = 'TEAM 2'; 
$week_3 = 'TEAM 3'; 
$week_4 = 'TEAM 4';

In the begining
Let us first assume that there was nothing to begin with.
 
The problem is the 'my' declarations. You can import the variable with 'use' like this:

#!/usr/local/bin/perl -w
use strict;
use diagnostics;
use CGI qw:)standard);
print header();

require schedule;

use vars qw($s_month $s_day $s_year);

print "\$smonth is $s_month ,\$sday is $s_day, \$syear is $s_year\n";


################### PM FILE #########################

#schedule

$s_month = 'Jun';
$s_day = '21';
$s_year ='2004';

$week_1 = 'TEAM 1';
$week_2 = 'TEAM 2';
$week_3 = 'TEAM 3';
$week_4 = 'TEAM 4';
 
Thanks for your help. It works fine .

In the begining
Let us first assume that there was nothing to begin with.
 
When you declare the variables with my,., Perl considers those values more important than the variables in the required file

In the begining
Let us first assume that there was nothing to begin with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top