Subject: | Copy file to directory does not DWIM |
Show quoted text
> perl -MIO::All -e'print "IO::All ", $IO::All::VERSION, "\n";'
IO::All 0.33
Show quoted text> perl -v
This is perl, v5.8.4 built for i386-linux-thread-multi
Show quoted text> uname -a
Linux thuathail 2.6.10-5-686 #1 Tue Apr 5 12:27:02 UTC 2005 i686 GNU/Linux
See attached script for working example of "DWIM" issue and my workaround.
#!/usr/bin/perl
use IO::All;
$test_file = io('test-file') < "This is contained in test-file\n";
$test_dir = io('test-dir')->mkpath;
# This works.
$test_file > io('test-file-2');
# This does not. Should work like 'cp test-file test-dir' but ...
# Can't locate object method "print" via package "IO::Dir" at /usr/share/perl5/IO/All.pm line 622.
eval {
$test_file > $test_dir;
};
warn $@;
# This is workaround and maybe part of solution.
$test_file > io($test_dir . '/' . $test_file->filename);