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


in reply to next unless - doesnt work?

Show us the complete loop. "If LABEL is omitted, the command refers to the innermost enclosing loop" (next)

update: better to do grep {$name eq $_} @names

Replies are listed 'Best First'.
Re^2: next unless - doesnt work?
by sweepy838 (Acolyte) on Apr 28, 2012 at 15:16 UTC
    ah i solved the problem using ne instead of eq :) and for some reason != didnt do the job but ne did.. strange?

      Not strange ;)

      != and == are for numeric context comparisons where eq/ne are for evaluating strings.

      Your original post didn't show any code relating to evaluations, so I, nor anyone else have any idea how this was part of your problem in the first place.

        not strange? when you think about it, it is strange! :)

      and for some reason != didnt do the job but ne did.. strange?

      Not at all. One is for numbers, the other for strings. You would've gotten a warning if you had use warnings on.

      String vs numerical
        my bad :( lol
      Not at all strange: ne is used for alphas; != for numbers.