http://www.perlmonks.org?node_id=1015084


in reply to Print only if pattern matches

because the lines,

123|1|456464|645646|4546|654~abc~dhghga~12.33.44.55.70~3713670 123|1|456464|645646|4546|654~abc~dhghga~12.33.44.55.70~3713670 123|1|456464|645646|4546|654~abc~dhghga~121322~456466874~8796896 123|2|456464|645646|4546|654~abc~dhghga~121322~456466874~6788708 123|2|456464|645646|4546|654~abc~dhghga~121322~456466874~6806
does not match your regular expression. So the grouping variable $2 and $3 has no values.