in reply to File name is long to copy

What error are you getting? You could be hitting some OS (which?) based path depth limit. Let perl tell you what happened:

copy( $source, $target ) or die "couldn't copy file $!";

Replies are listed 'Best First'.
Re^2: File name is long to copy
by hippo (Archbishop) on Apr 26, 2020 at 13:25 UTC

    Good advice. I'd include the paths too as the longer they are the more likely it is that one of them may have a typo.

    copy( $source, $target ) or die "couldn't copy file '$source' to '$tar +get': $!";

      the other files in that folder are copied but not this, if I reduce the name of the file then it works but that is not possible for me.

        SSCCE works for me.

        use strict; use warnings; use File::Copy 'copy'; use Test::More tests => 1; my $longname = 'foo_' . ('z' x 200); open my $fh, '>', $longname; print $fh "Hello!\n"; close $fh; my $toname = 'bar_' . ('z' x 200); ok copy ($longname, $toname) or diag $!;

        Maybe your O/S or your filesystem is the problem here?

Re^2: File name is long to copy
by harishnv (Sexton) on Apr 26, 2020 at 13:26 UTC

    "could not do at C:\sandboxes\Scripts\dummy.pl line 9" the error I got. any other solution? or can I copy the folders, sub folders and files in line of code? I'm using Windows

      Which version of Windows? It doesn't look like you tried what I suggested, note the $!

      copy( $source, $target ) or die "couldn't copy file $!"; #---------------------------------------------------^

        The error is "couldn't copy file No such file or directory at C:\sandboxes\Scripts\dummy.pl line 9."

        Windows 10 and the file is present because there are other files which I copy in that directory