dru145 has asked for the wisdom of the Perl Monks concerning the following question:
I thought my regex would not match on a .NO, so I'm not sure what's wrong. What should I do to make sure it won't match anything with a .NO in front of it? I haven't been coding much lately so please be kind if it's really obvious :-).NO..NO.K74apmd
Thanks,#!/usr/bin/perl -w use strict; # Script used to disable services that are not needed my @dirs = qw(rc0 rc1 rc2 rc3 rc4 rc5 rc6); my $expression = "autofs|apmd|isdn|lpd|netfs|nfs|nfslock|nscd|portmap |radvd|rstatd|rusersd|rwalld|rwhod|sendmail|ypbind|yppasswd|ypserv |ypxfrd"; my $result; my $i; for $i (@dirs){ opendir (DIR, "/etc/$i.d") or die "Can't open directory $_\n"; while (my $name = readdir(DIR)){ my $cmd1 = "/bin/mv /etc/$i.d/$name /etc/$i.d/.NO.$name" or print "/etc/$i.d/$name not found\n"; `$cmd1` if $name =~ /\b(K|S)\d{2}?$expression\b/; } closedir DIR; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Getting a Regex Not to Match Again
by sauoq (Abbot) on Oct 10, 2002 at 20:21 UTC | |
Re: Getting a Regex Not to Match Again
by japhy (Canon) on Oct 10, 2002 at 23:33 UTC | |
Re: Getting a Regex Not to Match Again
by mdillon (Priest) on Oct 10, 2002 at 20:43 UTC | |
Re: Getting a Regex Not to Match Again
by Anonymous Monk on Oct 10, 2002 at 20:55 UTC | |
by bcole23 (Scribe) on Oct 10, 2002 at 21:05 UTC |