phemal has asked for the wisdom of the Perl Monks concerning the following question:

suppose i have a file called as SENCONFIG. This file only contains the below global variables.
our $FLAG_IPV4 = "0"; our $FLAG_IPV6 = "1"; our $DEBUG = "0"; our @attack_client_info = ("15.1.1.11","root","root123","15. +1.1.0/24","eth0","172.16.232.52");
Now i use the below script to open the file and read the following in a string.
open CONFIG, "SENCONFIG" or die "Configuration file missing ...\n"; my $config = join "", <CONFIG>; eval $config or die "Failed to Evaluate SENCONFIG File...$@\n";
now when i use the print statement,it gives me the value of global varibale presen in the above file.
print $FLAG_IPV4; ### O/P is 0
Can anyone help me understanding how that values are coming from the file to above print statement................
Note: I am not using "use strict" option here because it gives complia +tion error stating variable not defined.

Replies are listed 'Best First'.
Re: issue with the global variable.
by revdiablo (Prior) on Feb 17, 2007 at 07:10 UTC
Re: issue with the global variable.
by ikegami (Patriarch) on Feb 17, 2007 at 07:01 UTC

    I am not using "use strict" option here because it gives compliation error stating variable not defined.

    To to be able to use strict, use our $FLAG_IPV4; in your program.

    Can anyone help me understanding how that values are coming from the file to above print statement

    eval EXPR. "In the first form, the return value of EXPR is parsed and executed as if it were a little Perl program." Of course, EXPR, in this case, is the contents of the "config" file.

Re: issue with the global variable.
by rodion (Chaplain) on Feb 17, 2007 at 09:26 UTC

    Can anyone help me understanding how that values are coming from the file to above print statement.....

    It looks like you could use more comments in this area, but I can't get by the suspicion that you are trying to learn how to use Perl in order to do un-welcome things to other people's machines. I'm commenting mostly as a flag to others, who might be reading through the thread fairly quickly.

Re: issue with the global variable.
by Zaxo (Archbishop) on Feb 17, 2007 at 06:53 UTC

    It prints zero for me. I don't much like eval for importing configuration, but your program seems correct.

    After Compline,
    Zaxo

      sorry i also get 0, that was a typing mistake