Hi Monks!
I have a simple form that takes some directories path and save it to a text file, my goal is to check the user input to make sure he/she doesn't input the same path twice. I am having a little problem with this, here is the code I have. If someone have a better way for me to do this will be great.
Here is some of the code that does that:
open(INPUTFILE, "$database") or die "cannot open file: $!";
while (<INPUTFILE> ) {
my $path_check=$_; #It should have all the entry from the db text fil
+e
chomp($path_check);
# $input{'nfirst'}) is one of the parameters from the form so it the
+value of $input{'slast'}
if( $path_check eq $input{'nfirst'}) || ($path_check eq $input{'slas
+t'}) ){
print "<b>Dont Print entry to db text file and exit the loop here<
+/b>";
}else{
print "Print New Value(s) to db text file here and exit the loop</
+b><br>";}
}
close(INPUTFILE);
_db sample
D:/myfiles/Test/
E:/pics/cgi-bin/new/
C:/temp/
D:/new/files/
F:/new/more/
C:/test/cgi-bin/ac/^ok
C:/new/files/ # This line shouldn't be allowed here, it is duplicate
+d.
Thanks a lot!!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.