Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
インターフェイス名と宛先を含むデータファイルがあります。すべての宛先をインターフェースでグループ化して、結果を繰り返して保存できるようにします。これが私の出力の例です:
eth0,1.1.1.1 eth0,1.1.1.2 eth1,1.1.1.1 eth1,1.1.1.2
一意のインターフェイス値をハッシュにダンプして、宛先の配列を作成するにはどうすればよいですか?
my %ifs; while ( my $line = <STDIN> ) { chomp $line; my ( $iface, $destination ) = split /,/, $line; push @{ $ifs{ $iface } }, $destination; }
動作するはずです。