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