my @y=(1..9); my $x=1; foreach my $value ( @y ) { if ( $value =~ /$x/ ) { print "without o\n"; } if ( $value =~ /$x/o ) { print "with o\n"; } ++$x; }