#!c:/perl/bin/perl -w $|++; use strict; print "Enter new student's name: "; chomp( my $student = ); open my $fh, '<', 'students.dat' or die "open failed: $!"; open my $tmp, '>', 'students.tmp' or die "open failed: $!"; my $found = 0; while (<$fh>) { print $tmp $_; $found = 1 if /^\Q$student\E$/i; } print $tmp $student, "\n" unless $found; close $fh; close $tmp; rename 'students.tmp', 'students.dat';