Well - I just ran your code here (on linux), adding "use strict", and adding "my" as appropriate, and it ran correctly (or at least I don't have any empty lines anywhere).
Ah - I know what the problem is:
When change the $network_if value here you actually modify the @tcp_utilization_metrics array - see the docs on the behavior of the foreach loop.foreach $network_if (@tcp_utilization_metrics) { local $if_name = $network_if; if ($network_if =~ /en/) { $network_if =~ substr ($network_if, 2, 0, "t"); }
If you reverse things you should be fine:
That said - you should "use strict" and replace those "local" with "my".foreach $if_name (@tcp_utilization_metrics) { local $network_if = $if_name; if ($network_if =~ /en/) { $network_if =~ substr ($network_if, 2, 0, "t"); }
Michael
In reply to Re: Re: Re: Simple hash assignment...or is it?
by mpeppler
in thread Simple hash assignment...or is it?
by arootbeer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |