in reply to Is there a Better work around rather than 9 If else Looping

Sushil - your code would be easier to read, maintain, expand and debug, if you used perl HASHES.

Hashes would also solve your multi-if logic.

Here is a structure outline to get you started:

my (%user_choice, %audit_rec); # Update: Parens added to fix syntax # Get User input into $user_choice{user}, $user_choice{module} .. and +$user_choice{host} #after reading the record, get it into %audit_rec like this: @audit_rec{ qw| time host user module msg | } = # This is a "Hash-sl +ice" split(']\[|]\s+|^\[',$audit_data); # Now, you can compare $user_choice{xxx} with $audit_rec{xxx} , and l +oop through values for xxx. # A more advanced technique would be to create a "dispatch table" hash + # Search for that on this site, if interested.
update:minor syntax update, to fix issue described by jdporter, below.

     "An undefined problem has an infinite number of solutions." - Robert A. Humphrey         "If you're not part of the solution, you're part of the precipitate." - Henry J. Tillman

Replies are listed 'Best First'.
Re^2: Is there a Better work around rather than 9 If else Looping
by jdporter (Paladin) on May 23, 2007 at 18:20 UTC

    Err...

    my %user_choice, %audit_rec;
    gives the warning
    Parentheses missing around "my" list at...
    and the error
    Global symbol "%audit_rec" requires explicit package name at...
    at least for those of us who use strict and warnings.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight