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

Discussion in 'Perl Misc' started by pankaj_wolfhunter@yahoo.co.in, Feb 20, 2007.

  1. Guest

    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
    , Feb 20, 2007
    #1
    1. Advertising

  2. wrote:
    > 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
    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
    Josef Moellers, Feb 20, 2007
    #2
    1. Advertising

  3. Guest

    On Feb 20, 12:53 pm, Josef Moellers <josef.moell...@fujitsu-
    siemens.com> wrote:
    > wrote:
    > > 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
    > --
    > 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?
    , Feb 20, 2007
    #3
  4. wrote:

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


    perldoc -f use
    ITYM perldoc -f require
    perldoc -f do

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
    Josef Moellers, Feb 20, 2007
    #4
  5. Guest

    On Feb 20, 2:39 pm, Josef Moellers <josef.moell...@fujitsu-
    siemens.com> wrote:
    > wrote:
    > > One more thing, whats the difference between USE, INCLUDE and DO?

    >
    > perldoc -f use
    > ITYM perldoc -f require
    > perldoc -f do
    >
    > --
    > Josef Möllers (Pinguinpfleger bei FSC)
    > If failure had no penalty success would not be a prize
    > -- T. Pratchett


    Thanks Joseph
    , Feb 20, 2007
    #5
  6. Tintin Guest

    wrote:

    > 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

    --
    Posted via a free Usenet account from http://www.teranews.com
    Tintin, Feb 21, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Bogenberger
    Replies:
    3
    Views:
    906
    Andreas Bogenberger
    Feb 22, 2008
  2. Eric
    Replies:
    10
    Views:
    461
  3. Eric
    Replies:
    0
    Views:
    257
  4. sed_y
    Replies:
    0
    Views:
    1,013
    sed_y
    Feb 15, 2012
  5. Yogi
    Replies:
    1
    Views:
    432
    Peter Makholm
    Sep 13, 2012
Loading...

Share This Page