string condition file - lookup logic

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jason@cyberpine.com

    string condition file - lookup logic

    Hello - looking for an efficient way in perl (been a while) to use a
    control file to pass or fail strings submitted to a perl program.

    I have a flat file allow.txt in the following format. It does not have
    to be in this format, it can be in regex format - and maybe should be.

    f1 -+f2 -+f3 -+f4 -+f6 ...

    records in the file may look as follows (for example)

    xx5 -j7 -j8 +g2 +j8
    xx4 +j7
    gg5
    xx7 +j7 -xs2 -557

    Each record may have one of more columns, where starting with the
    second column the value is to be labled an "and" or a "not" (+ or -)

    The + = must have this parm , the - = can't have this parm (again,
    might make sense to format the file in regex)

    using very simple perl program below, I'd like to bounce off the
    allow.txt file and display "rejected" if arugments passed comply, and
    "passed" if they do. My first inclination is to load the control file
    into a table and build lookup logic - but wanted to try the listgroup
    to

    test.pl:

    #!/usr/bin/perl
    use warnings;
    use strict;
    my $a1 = shift @ARGV;
    print $a1;


    so for example

    perl test.pl gg5
    "passed" (because no parms on file)

    perl test.pl xx7 j7 j8
    "passed" (because had the j7)

    perl test.pl xx7 j8
    "failed" (because did not have the j7)

    perl test.pl xx5 g2
    "failed" (because did not have the j8)

    perl test.pl xx5 g2 j8 j7
    "failed" (because had j7)

    If the solution will be easier by just formating the control file in
    (regex) condition format and somehow then testing the arguments
    against the file that would be ideal.

    Thanks for any help or information.
Working...