Viking has asked for the wisdom of the Perl Monks concerning the following question:
Also what is the best way to make a backup of a file? ie: just making a copy of the file. I want to make this code portable so using the external cp command isn't an option. And my way of doing it works fine but is there a better way? I would like this script to be completely self reliant so a module isn't an option either.
open DBFILE , "$dbFileName" or die $!; my @dbFile = <DBFILE>; close DBFILE; if (grep $cdLabel, @dbFile) { print "This CD ($cdLabel) is already in the database\n"; exit; } # `cp -f $dbFileName $dbFileName.BAK`; open DBFILEBK, ">$dbFileName.BAK" or die $!; for (@dbFile) { print DBFILEBK; } close DBFILEBK;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: grep problems and file copying issues
by davorg (Chancellor) on Jul 10, 2000 at 15:09 UTC | |
|
Re: grep problems and file copying issues
by reptile (Monk) on Jul 10, 2000 at 15:09 UTC | |
|
Re: grep problems and file copying issues
by le (Friar) on Jul 10, 2000 at 15:24 UTC | |
|
Re: grep problems and file copying issues
by chromatic (Archbishop) on Jul 10, 2000 at 21:36 UTC | |
by ambiguous (Novice) on Jul 11, 2000 at 03:01 UTC |