perl -wE '@a=(1,2,3); for(@a){/(2)/; say $1}' Use of uninitialized value $1 in say at -e line 1. 2 2