--- DATA ---- NAME AGE Sue 22 Sam 34 LUi 43 #### $|++; use strict; use Fcntl ':flock'; print "Enter new student's name: "; chomp( my $student = ); print "Enter new student's number: "; chomp( my $studentAge = ); open my $fh, '+<', 'students.dat' or die "open failed: $!"; flock $fh, LOCK_EX or die "flock failed: $!"; my $found = 0; while (<$fh>) { $found = 1 if /^\Q$student\E$/i; } print $fh $student ,"\t" , $studentAge ,"\n" unless $found; close $fh;