in reply to ensure ALL patterns in string

Why do you want the shortest? Here's one way to do it.

#!/bin/env perl use strict; use warnings; use List::Util qw(all); my $var = 'xyz'; if ( all { $var =~ $_ } ( qr/x/, qr/y/, qr/z/ ) ) { print "all in m8\n"; }

Replies are listed 'Best First'.
Re^2: ensure ALL patterns in string
by previous (Sexton) on Jan 22, 2016 at 21:40 UTC
    >Why do you want the shortest I find short more comprehensible in general...just the way I'm wired I guess. Irresponsible thank you for your solution.

      While the shortest may generally be the easiest to understand in most cases, that might not always be true. The motto of Perl is "There Is More Than One Way To Do It" (TIMTOWTDI). Quite often the SHORTEST way to do something is done in a rather obscure way. Perl is especially good for playing Golf with the code - where the winner is the one who uses the fewest characters to do a task. See Perl Golf 101's examples at the bottom. I think many of them are easier to understand before being shortened.

      I love coming to this site because I learn something new here each day. There are a lot of pro level Perl Golfers on this site, and it amazing just watching them driving or putting on the greens.