use strict; use warnings; my $text = "Signal\nLTE-FDD 4; Channel 2175"; my $band = ""; my $channel = ""; my $temp = ""; if($text =~ /Signal\nLTE-FDD [\d]{1,2}; Channel [\d]{3,4}/i) { $temp = $&; #store regex match $temp =~ /LTE-FDD [\d]{1,2};/i; $& =~ /[\d]{1,2}/i; $band = $&; #store regex match $temp =~ /Channel [\d]{3,4}/i; $& =~/[\d]{3,4}/i; $channel = $&; #store rege match } print "$band\t$channel\n";