Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to add one more name to that file and make sure the name doesn't exists already. I am trying somthing like :Mary Sue Kim
not working for me . Can someone help?print " Enter the number of student that you want to add\n"; my $std = <STDIN>; chomp $std; open(FILE, "$stdInfo") || die "couldn't open $stdInfo for reading"; my @in=<FILE>; close(FILE); open (FILE, ">$stdInfo") ||die "couldn't open $stdInfo for writing"; for (@in) { print FILE unless ( $_ =~ /^\Q$std\E\b/ ); print $std; } close(FILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: appending to a file
by davido (Cardinal) on Feb 26, 2004 at 05:18 UTC | |
by Anonymous Monk on Feb 26, 2004 at 06:46 UTC | |
by davido (Cardinal) on Feb 26, 2004 at 10:17 UTC | |
by revdiablo (Prior) on Feb 26, 2004 at 19:26 UTC | |
by Anonymous Monk on Feb 26, 2004 at 20:24 UTC | |
by davido (Cardinal) on Feb 26, 2004 at 23:43 UTC | |
| |
|
Re: appending to a file
by arden (Curate) on Feb 26, 2004 at 05:21 UTC | |
|
Re: appending to a file
by eyepopslikeamosquito (Archbishop) on Feb 26, 2004 at 05:59 UTC | |
|
Re: appending to a file
by Anonymous Monk on Feb 26, 2004 at 06:37 UTC | |
by davido (Cardinal) on Feb 26, 2004 at 23:54 UTC | |
by Anonymous Monk on Feb 27, 2004 at 05:41 UTC | |
by Anonymous Monk on Feb 27, 2004 at 17:06 UTC |