in reply to Passing a variable to a hash
You don't need $v1, $v2, etc. And in my opinion whenever you start naming variables (or hash keys) with numbers you probably should be using an array anyway. But sticking with the hash, this would probably do what you're attempting.
use strict; use warnings; my $system = 'something'; my %vlan; # --- Lines Omitted --- my $vl_number = 1; while( <STDIN> ) { chomp; $vlan{ 'VLAN' . $vl_number++ } = $_; } # --- Lines Omitted --- while( my ( $key, $value ) = each %vlan ) { print "Now checking: $system\_$key $value\n"; }
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Passing a variable to a hash
by rspishock (Monk) on Jan 04, 2012 at 11:51 UTC |