I'm trying to find a regex that will...
You don't need no steenkin' regex:
open my $fh, '<', 'whatever'; # or whatever my %hash = ( a => 0, e => 1, i => 2, o => 3, u => 4 ); while ( <$fh> ) { chomp; my $copy = $_; my @array; while ( my $char = lc chop $copy ) { no warnings 'uninitialized'; $array[ $hash{ $char } ] = 1; } say if ( grep $_, @array ) == 5; }
Pretty fast, too, you'll find...
Update: Hmm, if you take out the line no warnings 'uninitialized'; (and therefore remove use warnings or whatever from the start of the code), it seems to run nearly 20% faster still...Comments welcome.
Update 2: Oops, just realised that my code doesn't work! Change the contents of the inner while loop to:
$array[ $hash{ $char } ] = 1 if defined $hash{ $char };Which is what I had originally, before playing with no warnings 'uninitialized';. And then I didn't test properly.
Mea culpa.
In reply to Re: regex to find vowels in anyorder
by Not_a_Number
in thread regex to find vowels in anyorder
by varghees
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |