would probably be better written as:open FILEHANDLENAME, ">>storage.txt"; print FILEHANDLENAME $name," ",$num,"$email","\n";
The first line helps us keep certain things configurable, and will probably help us down the line when we want to modify the script slightly. The second line gives us some feedback if our file handle fails (you used this construct later in the script.... its valuable here too) The third line uses interpolation and is much easier to read than the original.$datafile = '/full/path/to/storage.txt'; #somewhere near the top ... open FILEHANDLENAME, ">>$datafile" or die "Couldn't open $datafile for + appending: $!"; print FILEHANDLENAME "$name $num $email\n";
Second:
What is that first line for? Are you purposefully throwing away the first line in the file? It could be that the first line in the datafile is for human consumption (i.e.$line=<FILE>; while ( my $line = <FILE> ) {
In that case a comment is warranted, to let everyone else know why that first line is being tossed.---------- BEGIN storage.txt ------------ NAME EMAIL PHONE Joe Blow joe@joe.com 123-1233 Jon Blow jon@jon.com 345-3455 ---------- END storage.txt ------------
All in all, it looks pretty good.
-Blake
In reply to Re: Phone Number Storage
by blakem
in thread Phone Number Storage
by Cobo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |