Vitali Pom
Vitali Pom

Reputation: 602

How to call a script with flags and get it's global vars?

I'm looking for something like this require "peacefullscript.pl -whiteflag"; the problem that this one doesn't work. What I want is to call a script with some flags and get the global variables it creates into the current script.

How can I do this easily?

Upvotes: 3

Views: 81

Answers (2)

mob
mob

Reputation: 118605

{
    local @ARGV = ("-whiteflag");
    do "peacefullscript.pl";
}

The local keyword creates a temporary copy of @ARGV that won't overwrite your original command line arguments.

Upvotes: 5

Barmar
Barmar

Reputation: 780889

@ARGV = ("-whiteflag");
require "peacefullscript.pl";

Upvotes: 4

Related Questions