sreek3502 has asked for the wisdom of the Perl Monks concerning the following question:
Below is the code snippet i have written, here the problem is $server variable cannot be passed inside the subroutines. How can i pass the value of a global variable inside a subroutine. Please help!
use strict; use warnings; my (@list,$server); @list = qw/server1.net server2.net server3.net/; foreach $server(@list) { #calling sub-routines command1(); command2(); } sub command1 { print $server; system("command1"); } sub command2 { print $server; system("command2"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing the value of a global variable inside a subroutine (updated)
by haukex (Archbishop) on Jul 08, 2018 at 15:56 UTC | |
|
Re: Passing the value of a global variable inside a subroutine
by haukex (Archbishop) on Jul 08, 2018 at 17:19 UTC |