catfile, like you are already doing for the source directory.
use strict; use warnings; use File::Copy qw( move ); use File::Spec::Functions qw( catfile ); my $src_dir = 'F:\\test'; my $dst_dir = 'F:\\oldbackups'; opendir(my $dh, $src_dir) or die("Can't open directory \"$src_dir\": $!\n"); my @dirs; while (defined(my $fn = readdir($dh))) { next if $fn eq '.' || $fn eq '..'; my $src_qfn = catfile($src_dir, $fn); next if !(-d $src_qfn && -M $src_qfn > 0); my $dst_qfn = catfile($dst_dir, $fn); move($src_qfn, $dst_qfn) or die("Can't move directory \"$src_qfn\" to \"$dst_qfn\": $!\n" +); }
In reply to Re: How to append a sub directory name alone to an existing dir path ?
by ikegami
in thread How to append a sub directory name alone to an existing dir path ?
by dilip_val
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |