in reply to Re^6: iterating through array and saving matches to new array
in thread iterating through array and saving matches to new array

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @ra = (1 .. 5); ;; my @rb = map { $_ == 3 ? () : $_ } @ra; dd \@rb; " [1, 2, 4, 5]


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^8: iterating through array and saving matches to new array
by Marshall (Canon) on Apr 23, 2018 at 20:40 UTC
    Same idea. The () is not "undef", it is no return value. In a foreach loop, a next statement might be used to skip processing of an input value.

      Exactly the same idea. I just meant to supply a worked example of something you had discussed in pseudo-ish code :)


      Give a man a fish:  <%-{-{-{-<