in reply to how to check condition and then pattern match

Seems that you want to parse an ifconfig output:

use Net::Int::Stats;