in reply to reading from file.
It looks to me like you may have your logic backwards. For any list of with more than one name, it will always print "not valid". I suspect that you meant something like
There are a number of other areas that could be cleaned up. For example, you probably should read the list of valid names before getting your name to test. A little more consistency in your use of brackets would also make your code easier to figure out (both for you and for us.)if input_name is in list: print "valid" else: print "not valid" This could be implemented with the following code: if (grep(/^$input$/, @names) { print "Valid\n"; } else { print "Not valid\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: reading from file.
by scripter87 (Novice) on Nov 13, 2013 at 21:10 UTC | |
by Kenosis (Priest) on Nov 13, 2013 at 21:32 UTC | |
by Eily (Monsignor) on Nov 13, 2013 at 21:36 UTC | |
by taint (Chaplain) on Nov 13, 2013 at 21:18 UTC |
In Section
Seekers of Perl Wisdom