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"); }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |