my %snr; while ( my \$line = shift @lines ) { chomp \$line; # (US0,--) 0.1 dB if ( \$line =~ m/SNR Margin:\s*(\d+)\s+(\d+)\s*\(US0,--\) 0.1 dB/ ) { ( \$snr{us0} ) = ( \$1 ); } # (US1,DS1) 0.1 dB if ( \$line =~ m/SNR Margin:\s*(\d+)\s+(\d+)\s*\(US1,DS1\) 0.1 dB/ ) { ( \$snr{us1}, \$snr{ds1} ) = ( \$1, \$2 ); } # (US2,DS2) 0.1 dB if ( \$line =~ m/SNR Margin:\s*(\d+)\s+(\d+)\s*\(US2,DS2\) 0.1 dB/ ) { ( \$snr{us2}, \$snr{ds2} ) = ( \$1, \$2 ); } # (US3,DS3) 0.1 dB if ( \$line =~ m/SNR Margin:\s*(\d+)\s+(\d+)\s*\(US3,DS3\) 0.1 dB/ ) { ( \$snr{us3}, \$snr{ds3} ) = ( \$1, \$2 ); } # (US4,DS4) 0.1 dB if ( \$line =~ m/SNR Margin:\s*(\d+)\s+(\d+)\s*\(US4,DS4\) 0.1 dB/ ) { ( \$snr{us4}, \$snr{ds4} ) = ( \$1, \$2 ); } } print q{US0:}, \$snr{us0}, qq{\n}; print q{US1:}, \$snr{us1}, q{ }, q{DS1:}, \$snr{ds1}, qq{\n}; print q{US2:}, \$snr{us2}, q{ }, q{DS2:}, \$snr{ds2}, qq{\n}; print q{US3:}, \$snr{us3}, q{ }, q{DS3:}, \$snr{ds3}, qq{\n}; print q{US4:}, \$snr{us4}, q{ }, q{DS4:}, \$snr{ds4}, qq{\n};