in reply to hash with an initial key/value of ' '
I would probably write the loop like this:while (<DATA>) { unless ( /\A#|^$/ ) { if (/nfs/) { ($remote_mt,$local_mt) = +(split)[0,1]; $hash{$remote_mt} = $local_mt; } } }
Just a little more robust in case some other field has 'nfs' in it.while (<DATA>) { next if /^\s*#/; my @f = split(' ', $_); if ($f[2] eq "nfs") { $hash{$f[0]} = $f[1]; } }
|
|---|