我一直在尝试编写一个脚本来预处理一些长文件列表,但我对Perl还没有信心(也没有能力)并且没有得到我想要的结果.
下面的脚本正在进行中,但我仍然坚持检查是否有重复,如果有人能让我知道我哪里出错了,我将不胜感激.处理重复项的块似乎与我找到的示例形式相同,但它似乎不起作用.
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, '<', $ARGV[0] or die "can't open: $!";
foreach my $line (<$fh>) {
# Trim list to remove directories which do not need to be checked
next if $line =~ m/Inventory/;
# MORE TO DO
next if $line =~ m/Scanned photos/;
$line =~ s/\n//; # just for a tidy list when testing
my @split = split(/\/([^\/]+)$/, $line); # separate filename from rest of path
foreach (@split) {
push (my @filenames, "$_"); …Run Code Online (Sandbox Code Playgroud)