string condition file - lookup logic

Discussion in 'Perl' started by jason@cyberpine.com, Aug 10, 2004.

  1. Guest

    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.
     
    , Aug 10, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. -
    Replies:
    12
    Views:
    715
    Remon van Vliet
    Jun 15, 2005
  2. gipsy boy
    Replies:
    1
    Views:
    3,112
    gipsy boy
    Jan 12, 2005
  3. Pawel
    Replies:
    1
    Views:
    1,520
    Ian Collins
    Oct 26, 2006
  4. spike
    Replies:
    8
    Views:
    1,544
    Steve Holden
    Feb 9, 2010
  5. Bill W.
    Replies:
    13
    Views:
    318
    Phillip Gawlowski
    May 9, 2011
Loading...

Share This Page