nimdokk has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; foreach my $dir (<DATA>) { chomp $dir; print "DIR: $dir\n"; if ( $dir =~ /\W+/ ) { print "\t$dir is not clean.\n"; } else { print "\t$dir is clean.\n"; }#close if }#close foreach __DATA__ test 1234 test_1234 test-1234 test 1234 test?1234 test+1234 test.1234
The first four items should return as "Clean" while the last four should return as "Not Clean". I've tried reversing to match Word (\w+) but because there are valid characters in all the items, they all return as "Clean". Any suggestions would be appreciated. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Problem
by FunkyMonk (Bishop) on Aug 01, 2007 at 18:00 UTC | |
by grinder (Bishop) on Aug 01, 2007 at 18:02 UTC | |
by FunkyMonk (Bishop) on Aug 01, 2007 at 18:14 UTC | |
|
Re: Regex Problem
by ikegami (Patriarch) on Aug 01, 2007 at 18:55 UTC | |
|
Re: Regex Problem
by ww (Archbishop) on Aug 01, 2007 at 17:56 UTC | |
by nimdokk (Vicar) on Aug 01, 2007 at 18:05 UTC |