Newbie...Not able to include a file in perl script

P

pankaj_wolfhunter

Greetings,
I am entirely new to perl. Just starting with it.
I have a file (test.env) which I want to make use in (code.plx) file.
test.env contains variables which will be used in code.plx.

I tried:
#!/usr/bin/perl

$class='/full_path/test.env';

require $class;

But I am getting some "Bareword" found kinda error.

Can anyone correct me here?

TIA
 
J

Josef Moellers

Greetings,
I am entirely new to perl. Just starting with it.
I have a file (test.env) which I want to make use in (code.plx) file.
test.env contains variables which will be used in code.plx.

I tried:
#!/usr/bin/perl

$class='/full_path/test.env';

require $class;

But I am getting some "Bareword" found kinda error.

Can anyone correct me here?

First of all "getiing some "Bareword" found kinda error" is some
unusable kinda description of a problem.

The "requires" directive requires the file to be a valid Perl script. If
it's a collection of shell-like environment settings, e.g.
debug=true
temp=/var/tmp
then, obviously, it won't work.

You have a couple of options:
1. convert this into a valid Perl script, e.g.
$ENV{debug} = 'true';
$ENV{temp} = '/var/tmp';
2. write a short function which reads and parses the file, or find a
suitable module which does that for you.

Josef
 
P

pankaj_wolfhunter

First of all "getiing some "Bareword" found kinda error" is some
unusable kinda description of a problem.

The "requires" directive requires the file to be a valid Perl script. If
it's a collection of shell-like environment settings, e.g.
debug=true
temp=/var/tmp
then, obviously, it won't work.

You have a couple of options:
1. convert this into a valid Perl script, e.g.
$ENV{debug} = 'true';
$ENV{temp} = '/var/tmp';
2. write a short function which reads and parses the file, or find a
suitable module which does that for you.

Josef
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett- Hide quoted text -

- Show quoted text -

Thanks Joseph, Bob. Sorry as being a newbie, I didnt know much about
the etiquette of this group.
I'll keep these things in mind.

The file which I am trying to include is a shell script and not a perl
one.
I think there lies my problem.

One more thing, whats the difference between USE, INCLUDE and DO?
 
T

Tintin

Thanks Joseph, Bob. Sorry as being a newbie, I didnt know much about
the etiquette of this group.
I'll keep these things in mind.

The file which I am trying to include is a shell script and not a perl
one.
I think there lies my problem.

I have no idea what leap of logic made you believe you could include a
shell script in the Perl program.

Shell script != Perl
Perl != Shell script
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top