#!c:/perl/bin/perl -w $|++; use strict; use Fcntl ':flock'; print "Enter new student's name: "; chomp( my $student = ); 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, "\n" unless $found; close $fh;