in reply to mvi -- mv+vi (+ln+rm+cp+mkdir)
What about using symlink on directories (I needed it)?
Just a simple example that works quite well (I haven't tested it extesively).
if( (-f $file) and ( ! link( $file, $new )) ) { warn "Can't link $file to $new: $!\n"; } elsif( (-d $file) and ( ! symlink( $file, $new )) ) { warn "Can't symbolic link $file to $new: $!\n"; } else { $did= 'ln'; }
In the ProcessFile subroutine.
And recursive directory structure creation (just like mkdir -p)?
This is made using the subroutine make_path in File::Path instead of mkdir to create directories.
use File::Path qw< make_path >; # this should be added at the t +op sub MakeNewDirs { my( @newDirs )= @_; for my $dir ( @newDirs ) { if( -d $dir ) { warn "mkdir $dir: Already exists.\n"; } elsif( make_path( $dir ) ) { warn "mkdir $dir\n"; } else { warn "Can't mkdir $dir: $!\n"; } } }
Anyway thank you for sharing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: mvi -- mv+vi (+ln+rm+cp+mkdir) (ln -s, mkdir -p)
by tye (Sage) on Aug 02, 2010 at 21:02 UTC | |
by runrig (Abbot) on Aug 02, 2010 at 21:52 UTC |