how
about sorting the letters first:
$var="meqgvn";
$sortedvar=join("", sort(split("",
$var)));
if
($sortedvar eq "egmnqv") { print
"yes!\n";}
--ken
-Original Message-From: Dax T. Games
[mailto:[EMAIL PROTECTED]Sent: Tuesday, September 02, 2003
12:26 PMTo: Perl UsersS
$Bill Luebkert wrote:
> Dax T. Games wrote:
>
>
>>I have a list of characters. I need to get a list of all possble
>>sequences of these characters for example.
>>
>>I have a string that consists of '-mevqgn' I need to pattern match any
>>combination of 'mevqgn' with a preceding - or --.
>>
>
At 01:26 PM 9/2/2003, Dax T. Games wrote:
I have a
list of characters. I need to get a list of all possble sequences
of these characters for example.
I have a string that consists of '-mevqgn' I
need to pattern match any combination of 'mevqgn' with a preceding - or
--.
Right now this is w
Equally dirty, but possibly more flexible:
$_='aSdFgHjk'; # Letters to look
for.
$alpha1=lc(join('',sort(split(//;
$LS_Val=shift;
$LS_Val=~s/^-//g; # Drop preceding dashes
$alpha2=lc(join('',sort(split(//,$LS_Val;
if
($alpha1 eq $alpha2) {print "Pattern found!\n";}
It looks like you may be doing standard command line option
parsing (or almost standard as the '--' prefix is reserved
for long option names). If this is so, look at GetOpt::Std .
For a subroutine that does what you specified (tested):
sub is_DTG_Option ($)
{
my $opt = shift;
return 0
Wow... looks like some good replies to this one. Here's a less
elegant, recursive approach (until I learn map :-)
#!perl -w
# print all 720 permutations using letters: e m v q g n
use strict;
sub mutate {
my ($in) = @_;
if (length($in) == 6) {
print "$in\n";
$in = '';
} else {
On Tue, 2 Sep 2003, Dax T. Games wrote:
> I have a list of characters. I need to get a list of all possble sequences of these
> characters for example.
>
> I have a string that consists of '-mevqgn' I need to pattern match any combination
> of 'mevqgn' with a preceding - or --.
>
> Right now th
Here
is another variation...
#!/usr/bin/perl
check('-mevqgn');check('-memqgn');check('-ngmevq');check('--meqvgn');
sub check{ my $LS_Val = shift;
if ($LS_Val =~ /-{1,2}([mevqgn]{6})/ and
unique_chars($1)) { print "Ding
Ding! $LS_Val is good!\n"; } else
{ pr
Have you tried playing around with character sets? Something like
$target = 'mevqgn';
$length_target = length $target;
if ( $LS_Val =~ /-{1,2}[$target]{$length_target}/ ) {
#do something
}
Whether the above would work for you would depend on whether the code
can ignore positive matches on $LS_
I wanted to use tr but was uanble to accomplish the
task that way. So I used regex like the following:
use strict;
my %MCTWW = qw(m -1 e -1 v -1 q -1 g -1 n -1);my $MyCharsToWorkWith =
\%MCTWW;
$_ = '--mepqgn ';
if ( ! /-{1,2}(\S+)/ ) { printf "Expecting a hyphen
or two floowed
Dax T. Games wrote:
> I have a list of characters. I need to get a list of all possble
> sequences of these characters for example.
>
> I have a string that consists of '-mevqgn' I need to pattern match any
> combination of 'mevqgn' with a preceding - or --.
>
> Right now this is what I am d
11 matches
Mail list logo