in reply to Default variable within loops

Here another option using smart matching:

use Modern::Perl; my @a = 1 .. 10; my @b = 5 .. 14; say grep $_ ~~ @b, @a;

Output:

5678910

Hope this helps!

Replies are listed 'Best First'.
Re^2: Default variable within loops
by cheekuperl (Monk) on Jun 21, 2012 at 03:23 UTC
    Is this Perl version specific?

      Smart matching started in Perl 5.10