open (INPUT, "<", $ARGV[0]) || die "\nError: File Read \"$ARGV[0]\"\nError: $!\n\n"; while ( $line = ) { if ( $line =~ /^(b|f)/) { print $line; } } close INPUT; #### b=23 y=0x11 arg=0x70 def=0x1 val=0x234 checking system b=71 y=0x35 arg=0x87 def=0x3 val=0x76d h=reg.k2.io.chk 0x2001 b=54 y=0x23 arg=0x78 def=0x2 val=0x65b f chk.fin.reg.m_cwr 0x213 b=54 y=0x23 arg=0x78 def=0x2 val=0x65b checking system b=40 y=0x90 arg=0x34 def=0x5 val=0x2197 f ref.grf.pin.clk_trg 0x0021 #### b=54 y=0x23 arg=0x78 def=0x2 val=0x65b f chk.fin.reg.m_cwr 0x213 b=40 y=0x90 arg=0x34 def=0x5 val=0x2197 f ref.grf.pin.clk_trg 0x0021 The b must be from f From the b and f I want to get the from b (y, arg and def) and f (\w+ - chk.fin.reg.m_cwr /ref.grf.pin.clk_trg )