in reply to Getting element of array with a match

You can build a regular expression from your string. If you just want the characters appear in the same order, you can place .* between each two characters. The regular expression for "filswjs" will then be f.*i.*l.*s.*w.*j.*s, which means "f, than anything, then i, then anything, then l, ...". Then just grep the arrays for matches:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my @array1 = qw(fil01_sw100056_02.04.js mn_sw100868_15.17.js roof_app01_sw12345_26.02.hex roof_dir01_sw101481_01.32 +.dir); my @array2 = qw(fil01_sw100056_02.03.js mn_sw100868_15.16.js roof_app01_sw101483_25.05.hex roof_dir01_sw101481_01.2 +5.dir); my $string = 'filswjs'; (my $regex = $string) =~ s/(.)(?=.)/$1.*/g; say for grep /$regex/, @array1, @array2;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Getting element of array with a match
by Eily (Monsignor) on Dec 09, 2014 at 14:31 UTC

    If I understood correctly, OP wanted to ignore everything but alphabetic ("string") characters, as opposed to numbers ("no") and special characters. So the regex would have to be $regex = join "[^a-zA-Z]*", split //, $string;

    Though the more I look at the question, the more it looks like an XY problem