For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2004 > To include another file in perl program









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author To include another file in perl program
Durai

2004-04-30, 1:18 am

Hello All,

I have the following perl program.

#!/opt/perl/bin/perl -w

require "test_init.pl" or die("Can't require test_init.pl");
require "configure.pl" or die("Can't require configure.pl");
require "common_functions.pl" or die("Can't require common_functions.pl");

In this, configure.pl and common_functions.pl needs test_init.pl file. The
above one is not working. I have the following error.

$ perl runtest.pl
configure.pl did not return a true value at runtest.pl line 4.

It works fine only after I included test_init.pl file in configure.pl and
common_functions.pl files.

Why it doesn't work?

Regs,
Durai.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004

Charles K. Clarkson

2004-04-30, 1:18 am

Durai <tech_durai@yahoo.com> wrote:
:
: $ perl runtest.pl
: configure.pl did not return a true value at runtest.pl
: line 4.

At the bottom of each required file place a 1 like
this:

1;


It should be on the last line. Let us know if that
fixes your problem.


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

Durai

2004-04-30, 1:18 am

Hi,
It works fine. Thanks.
But I don't know about 1; action?

Is it the return value?

Regs,
Durai.

----- Original Message -----
From: "Charles K. Clarkson" <cclarkson@htcomp.net>
To: "'Durai'" <tech_durai@yahoo.com>; <beginners@perl.org>
Sent: Friday, April 30, 2004 9:00 AM
Subject: RE: To include another file in perl program


> Durai <tech_durai@yahoo.com> wrote:
> :
> : $ perl runtest.pl
> : configure.pl did not return a true value at runtest.pl
> : line 4.
>
> At the bottom of each required file place a 1 like
> this:
>
> 1;
>
>
> It should be on the last line. Let us know if that
> fixes your problem.
>
>
> HTH,
>
> Charles K. Clarkson
> --
> Mobile Homes Specialist
> 254 968-8328
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004
Charles K. Clarkson

2004-04-30, 9:05 am

Durai <tech_durai@yahoo.com> wrot:
:
: It works fine. Thanks.
: But I don't know about 1; action?
:
: Is it the return value?

Yes. Read perlfunc 'require':


"The file must return true as the last statement to
indicate successful execution of any initialization
code, so it's customary to end such a file with 1;
unless you're sure it'll return true otherwise. But
it's better just to put the 1;, in case you add more
statements."


HTH,


Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

Durai

2004-04-30, 9:05 am

Hi,

Still I have some problem.

runtest.pl
----------

#!/opt/perl/bin/perl -w
use strict;

require "test_init.pl" or die("Can't require test_init.pl");
require "configure.pl" or die("Can't require configure.pl");
require "common_functions.pl" or die("Can't require common_functions.pl");

Here, common_functions.pl file uses the variables which are in test_init.pl
file.
But common_functions.pl couldn't access the variables which are in
test_init.pl file.

$ perl runtest.pl
Global symbol "$PROD_TESTS" requires explicit package name at
common_functions.pl line 11.
Global symbol "$LOG_DIR" requires explicit package name at
common_functions.pl line 14.
Global symbol "$TOTAL_TEST_LOG" requires explicit package name at
common_functions.pl line 19.
Global symbol "$TOTAL_TEST_LOG" requires explicit package name at
common_functions.pl line 19.
Global symbol "$PROD_TESTS" requires explicit package name at
common_functions.pl line 24.
Compilation failed in require at runtest.pl line 6.
$

----- Original Message -----
From: "Charles K. Clarkson" <cclarkson@htcomp.net>
To: "'Durai'" <tech_durai@yahoo.com>; <beginners@perl.org>
Sent: Friday, April 30, 2004 9:25 AM
Subject: RE: To include another file in perl program


> Durai <tech_durai@yahoo.com> wrot:
> :
> : It works fine. Thanks.
> : But I don't know about 1; action?
> :
> : Is it the return value?
>
> Yes. Read perlfunc 'require':
>
>
> "The file must return true as the last statement to
> indicate successful execution of any initialization
> code, so it's customary to end such a file with 1;
> unless you're sure it'll return true otherwise. But
> it's better just to put the 1;, in case you add more
> statements."
>
>
> HTH,
>
>
> Charles K. Clarkson
> --
> Mobile Homes Specialist
> 254 968-8328
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com