How to handle filenames with spaces?

前端 未结 7 785
后悔当初
后悔当初 2020-12-11 03:37

I use Perl on windows(Active Perl). I have a perl program to glob the files in current folder, and concatenate them all using dos copy command called from within using syste

7条回答
  •  攒了一身酷
    2020-12-11 04:30

    system is rarely the right answer, use File::Copy;

    To concatenate all files:

    use File::Copy;
    my @in = glob "*.mp3";
    my $out = "final.mp3";
    
    open my $outh, ">", $out;
    for my $file (@in) {
        next if $file eq $out;
        copy($file, $outh);
    }
    close $outh;
    

提交回复
热议问题