Hi everyone..
I am trying to write a perl code which appends a text file after taking two inputs from the user. It saves the file in tab delimited format. I have the input text file attached here. Now I want the file to check if the user given input is already present only in the first column of the text file. If it is present, then it doesn't append anything in the file. Otherwise it should append it.
Below is my code which is just comparing..not appending!
print "Please write your name and address below\n";
$input=<STDIN>;
$input1=<STDIN>;
chomp $input;
chomp $input1;
open FILE, "C:/Software/new1.txt" or die $!;
while (<FILE>) {
chomp;
($user)=split("\s");
if ($input=~/$user/) {
print "User name already exists.\n";
#close (FILE);
}
else {
#open FILE, ">>C:/Software/new1.txt" or die $!;
print FILE "$input\t$input1";
}
}
close (FILE);
exit;
could you please help me..
Thanks