my $stdInfo="/home/stdInfo"; print " Enter the number of student that you want to delete\n"; my $std = ; #Don't forget to get rid of the newline character from the input chomp $std; #Open the file and read it in: open(FILE, "$stdInfo") || die "couldn't open $stdInfo for reading"; #Each line is stored in an array my @in=; close(FILE); #Now open the same file again for output open (FILE, ">$stdInfo") ||die "couldn't open $stdInfo for writing"; #Now print out everything except what you want to delete: for (@in) { print FILE unless ( $_ =~ /^$std/ ); } close(FILE);