wrapper script calling anotherr script

Discussion in 'Perl Misc' started by bjlockie, Sep 15, 2012.

  1. bjlockie

    bjlockie Guest

    I want to create a wrapper script (testa.pl) that defines variables (like $b) and can execute another perl program (testb.pl) that can access those variables.

    I tried:
    $ testa.pl 'testb.pl' but it didn't work.
    I don't think eval is what I need but 'use' doesn't work on variables.


    ::::::::::::::
    testa.pl
    ::::::::::::::

    #!/usr/bin/perl -w

    #use strict;
    use warnings;

    my $realScript = $ARGV[0];

    (defined($realScript)) or die "Must specify a script\n";

    print "This is $0\n";
    my $b = 10;
    eval $realScript;

    print $@;



    ::::::::::::::

    testb.pl

    ::::::::::::::

    #!/usr/bin/perl -w

    use strict;
    use warnings;

    print "This is $0, b=$b (should be 10)\n";
     
    bjlockie, Sep 15, 2012
    #1
    1. Advertising

  2. bjlockie

    bjlockie Guest

    On Saturday, September 15, 2012 1:24:13 AM UTC-4, Eli the Bearded wrote:
    > In comp.lang.perl.misc, bjlockie <> wrote:
    >
    > > I want to create a wrapper script (testa.pl) that defines variables

    >
    > > (like $b) and can execute another perl program (testb.pl) that can

    >
    > > access those variables.

    >
    >
    >
    > It's a strange thing to want to do, but Perl knows how to do this.
    >
    > You want to use "do".


    I am using someone else's scripts that each have config data by using 'use configa'.
    There is 'configb', 'configc', etc.
    The current way of changing the config is to modifiy each 'use' in all the scripts.
    With the wrapper, I can have the 'use configx' in one place and use 'do' to call the other scripts.
     
    bjlockie, Sep 15, 2012
    #2
    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. Peter Michaux
    Replies:
    19
    Views:
    1,252
    Kenny McCormack
    Sep 10, 2008
  2. eric.frederich

    Python without wrapper script

    eric.frederich, Dec 2, 2009, in forum: Python
    Replies:
    5
    Views:
    2,455
    Jonathan Hartley
    Dec 3, 2009
  3. Replies:
    3
    Views:
    800
    Markus Wichmann
    Jan 15, 2012
  4. qazmlp
    Replies:
    5
    Views:
    93
    Michael Meissner
    Jan 2, 2005
  5. Replies:
    0
    Views:
    181
Loading...

Share This Page