Perl – Regular expressions?

I am asking about is that:
I want to save Regex rules in a file
and from the script(perl script) I want to match URL content with the rules in the file:S
Note:the file doesn’t content normal words, it content Regex rules
and i want to match the URL with each regex rule saved in the file
it’s like htaccess idea? is that possible?

Comments

  1. covinher says:

    example below:
    edit: regexes in the file don’t have the delimiters (i.e. ^foo and not /^foo/)

    #!/usr/bin/perl
    #
    use strict;

    if (scalar(@ARGV) < 1) {
    print STDERR "Usage: $0 URL [URL] \n";
    exit(1);
    }

    my $fh;
    open($fh, "<rules") or die "$!";

    my @rules = <$fh>;

    foreach my $url (@ARGV) {
    $url =~ s#^http://##;
    $url =~ s#^https://##;
    foreach my $rule (@rules) {
    chomp $rule;
    if ($url =~ m/$rule/) {
    print "match for $rule for $url\n";
    }
    }
    }
    close($fh);

legitimate work from home jobs | Event Planning Bay Area | rent video games | Homeloans | Plumbing Courses in Manchester | increase fertility | Green Drink | Photo Keyring | Vitamin D Deficiency Symptoms | skip bags | Order Fulfillment Software | virtual receptionist | Educators Credit | bodybuilding workouts | window cleaning
Poker Software