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
In reply to Re: Passing a variable to a hash
by davido
in thread Passing a variable to a hash
by rspishock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |