http://qs321.pair.com?node_id=1140761

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

I'm trying to capture the first value from a list of values. My script has multiple sub sections. In one, we have declared global variables and then as per requirement we are using them. As per my requirement, I'm calling linux servers(which has 4 values), and try to capture the first value. It is not coming as expected.
@mylnxsrvrs = split(',', $myhash{SBLLNXSRVRHOSTS}); @mywinsrvrs = split(',', $myhash{SBLWINSRVRHOSTS}); @mysblroot = split(',', $myhash{SIEBELROOT}); @mysblsrvrpath = (',',$myhash{SBLSRVRPATH}); foreach $a (@mylnxsrvrs) {my $lnxsrvr = "$a"; printf "$a $lnxsrvr\n\n";} printf "$lnxsrvr\n"; printf "@mylnxsrvrs";

The output looks like this --
dvapoms1 dvapoms1
dvapoms2 dvapoms2

dvapoms1 dvapoms2

If I'm trying to assign the value, it is giving junk result --
my $lnxsrvrs = "@mylnxsrvrs"; printf "$lnxsrvrs";
The output shows -- 1