pritesh has asked for the wisdom of the Perl Monks concerning the following question:
Problem is, if I choose the Primary data center, it sets the symcli value correct. If, I run the script again, it outputs as if its set the secondary_server value, but when I try checking the value of symcli_connect, its still the first one. As a result its not working the way its supposed to. Looks like the value of $ENV variable is not being passed outside the if loop. I am a beginner....to Perl and programming as well. Can someone let me know where I am going wrong ?#!/usr/bin/perl use warnings; use strict; print "Choose The Datacenter\n"; print "1. \Primary\n"; print "2. \Secondary\n"; print "Enter 1 or 2:"; $ENV{"SYMCLI_CONNECT"} = ""; our $datacenter=<STDIN>; if ($datacenter == 1) { print "\t\t\t***Setting Environment for Primay***\n"; $ENV{"SYMCLI_CONNECT"} = "primary_server"; system ("symcfg list"); } elsif ($datacenter == 2) { print "\t\t\t\t***Setting Environment for Secondary***\n"; $ENV{"SYMCLI_CONNECT"} = "secodnary_server"; system ("symcfg list"); } else { print "Please enter only 1 or 2 \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing value from IF loop
by jethro (Monsignor) on Sep 24, 2010 at 13:11 UTC | |
|
Re: Passing value from IF loop
by Utilitarian (Vicar) on Sep 24, 2010 at 15:10 UTC | |
by dasgar (Priest) on Sep 24, 2010 at 17:28 UTC | |
|
Re: Passing value from IF loop
by toolic (Bishop) on Sep 24, 2010 at 13:26 UTC | |
|
Re: Passing value from IF loop
by JavaFan (Canon) on Sep 24, 2010 at 15:04 UTC | |
|
Re: Passing value from IF loop
by afoken (Chancellor) on Sep 25, 2010 at 04:53 UTC |