|
ru.perl- RU.PERL ---------------------------------------------------------------------- From : Maxx L. Mazour 2:5020/400 06 Aug 2003 11:44:39 To : All Subject : Hаписать копировщик файлов. -------------------------------------------------------------------------------- Привет All. Подскажите оптимальный путь как это сделать. Write a program that copies files. The usage of the program is: copy.pl <source> <destination> Copies the <source> file to <destination>. If <destination> is a directory, copies <source> into that directory. Otherwise makes a copy of <source> in the current directory. You must use robust error-checking in this assignment. In particular, you should exit the program (with an appropriate error message, and perhaps a usage message) if: Two command-line arguments were not given The source file does not exist or can't be opened The destination is a directory, and the directory can't be written into The destination file already exists (see Extra Credit below) The $! variable will contain the appropriate error messages for most of these errors, so be sure to print the value of the $! variable in your die statement. I will be testing every error scenario mentioned above so be sure to test your program against all of these possible error scenarios before submitting your application. Your program must create an EXACT copy of the file it's copying. You should definitely compare the byte count of your source and destination files. You will loose points if your copy is not exactly the same as the original. As always, the user interface to your application is important. Make sure to notify the user with useful status messages of either a failure or success in the copy operation attempted. TIP: To make your error messages look nicer to the user (by showing them only useful error feedback) you should use the newline ("\n") character at the end of your "die" function print statement. Like this: or die "Can't open $destination for writing: $!.\n"; The purpose of using the newline ("\n") character in the die function statement is to suppress the printout of the line number where your code failed. So with the newline character your error prints as: Can't open recipes.txt for writing: Permission denied. Instead of: Can't open recipes.txt for writing: Permission denied at copy.pl line 215. File overwrite warning. If the destination file already exists, warn the user, and ask them if they want to overwrite the file. If they do, then overwrite it. Recursive file copy. Allow another usage so that if the "-r" command line argument is specified, and the destination is a directory, then the source directory and files in the source directory and any directories and files below the source directory should be copied into the destination directory. copy.pl -r <source directory> <destination> - --- [ася:10097303] Писать сюда:*gatomon(a)mail.ru*! Max /Фoрнит/ --- ifmail v.2.15dev5 * Origin: Can you feel the Power? (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.perl/21380d099d63.html, оценка из 5, голосов 10
|