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


in reply to Foreach loop

If you are going to use a for loop, I'd use something along the lines of ...
my $keys = "5 10 14 16 17 20 25 26 38 1 42 + 47 54"; my $substr = '1'; print "\nExist" if $_ eq $substr for split /\s+/, $keys;
Having said that, the OP has the whiff of homework

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: Foreach loop
by marinersk (Priest) on Sep 27, 2013 at 23:56 UTC
    It might have the whiff of homework, but at least the OP posted functional code. It leaves us able to prod in the right direction without necessarily giving the whole house away.

    But yeah, some care was warranted. :-)