You might want to look at File::Spec, File::Path, and File::Copy. File::Spec is great for performing portable directory and filename operations (you don't have to remember which way the slashes should go). File::Path makes it very easy to create directory trees without having to specifically create all of the intermediate directories. File::Copy is used to copy or move files. As with any function call, you should verify it worked by either performing an independent test or by checking the return value.
For example:HTHuse strict; use warnings; use File::Path; use File::Copy; use File::Spec; # Assemble a new dir name and create it my $dirpath = File::Spec->catdir( 'C:', 'dir1', 'dir2' ); mkpath( $dirpath ); # make sure the dir we tried to create exists, using -d (one option) my $install_error = 0; unless( -d $dirpath ) { $install_error = 1; } # (stuff if mkpath failed) my $pathfile = File::Spec->catfile( $dirpath, 'myfile.txt' ); my $copy_status = copy( 'myfile.txt', $pathfile ); if( $copy_status == 1 ) { print " copied myfile.txt to $dirpath\n"; } else { print " *** Error copying file: $!\n"; }
In reply to Re: mkdir on Windows 98
by bobf
in thread mkdir on Windows 98
by shn4002
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |