diff --git a/lib/Directory/Simplify/FileHash.pm b/lib/Directory/Simplify/FileHash.pm index 54a0eb8..921573c 100644 --- a/lib/Directory/Simplify/FileHash.pm +++ b/lib/Directory/Simplify/FileHash.pm @@ -43,7 +43,7 @@ sub add { $self->{_entries}->{$hash} = []; } push @{$self->{_entries}->{$hash}}, $file; - &{$callback}($file) if ref $callback eq 'CODE'; + $callback->($file) if ref $callback eq 'CODE'; } $self->{_files_in_hash}->{$file->{name}} = 1; } diff --git a/lib/Directory/Simplify/Instruction/Generator.pm b/lib/Directory/Simplify/Instruction/Generator.pm index 9fe7571..b8a474e 100644 --- a/lib/Directory/Simplify/Instruction/Generator.pm +++ b/lib/Directory/Simplify/Instruction/Generator.pm @@ -42,7 +42,7 @@ sub buckets { next ELIMINATOR if $self->_entry_should_be_skipped($entry); foreach my $bucket_idx (0 .. $#these_buckets) { - if (&_entries_are_hard_linkable($these_buckets[$bucket_idx]->[0], $entry)) { + if (_entries_are_hard_linkable($these_buckets[$bucket_idx]->[0], $entry)) { push @{$these_buckets[$bucket_idx]}, $entry; next ELIMINATOR; } @@ -71,16 +71,16 @@ sub _entries_are_hard_linkable { my ($entry_a, $entry_b) = @_; # obviously, if the sizes aren't the same, they're not the same file - unless (&_entries_sizes_match($entry_a, $entry_b)) { + unless (_entries_sizes_match($entry_a, $entry_b)) { return 0; } # they're the same file, don't try it - if (&_entries_are_already_hard_linked($entry_a, $entry_b)) { + if (_entries_are_already_hard_linked($entry_a, $entry_b)) { return 0; } - if (&_entries_contents_match($entry_a, $entry_b)) { + if (_entries_contents_match($entry_a, $entry_b)) { return 1; } return 0; @@ -123,7 +123,7 @@ sub _entries_sizes_match { sub _entries_contents_match { my ($entry_a, $entry_b) = @_; - my $contents_same = (0 == &File::Compare::compare($entry_a->{name}, $entry_b->{name})); + my $contents_same = (0 == File::Compare::compare($entry_a->{name}, $entry_b->{name})); # warn about hash collision unless ($contents_same) { @@ -168,7 +168,7 @@ sub instructions { target => $entry, ); } - if (&Scalar::Util::refaddr($most_linked_entry) != &Scalar::Util::refaddr($oldest_entry)) { + if (Scalar::Util::refaddr($most_linked_entry) != Scalar::Util::refaddr($oldest_entry)) { # most_linked_entry should get its timestamp updated push @inst, Directory::Simplify::Instruction::CopyTimestamp->new( source => $oldest_entry, diff --git a/simplify_static_dir-main.pl b/simplify_static_dir-main.pl index 78ecfe4..41a2e04 100755 --- a/simplify_static_dir-main.pl +++ b/simplify_static_dir-main.pl @@ -117,15 +117,15 @@ require Directory::Simplify::Utils; sub HELP_MESSAGE { my $fh = shift; - &pod2usage( + pod2usage( -verbose => 1, -exitval => 0, ); } MAIN: { - &getopts('vfm:M:z', \ my %opts) - || &pod2usage( + getopts('vfm:M:z', \ my %opts) + || pod2usage( -exitval => 2, -msg => "Try '$0 --help' for more information", ); @@ -145,7 +145,7 @@ MAIN: { print STDERR 'Finding files...' if $verbose; - &find(sub { + find(sub { # outright skip directories (don't report skip) return if -d $File::Find::name; @@ -214,7 +214,7 @@ MAIN: { my $report_every = 1; # seconds my $processed_bytes = 0; my $last_report = time; - my $total_size_hr = sprintf "%0.4G %s", Directory::Simplify::Utils::hr_size(&sum(map { $_->{size} } @files) or 0); + my $total_size_hr = sprintf "%0.4G %s", Directory::Simplify::Utils::hr_size(sum(map { $_->{size} } @files) or 0); my $cb; if ($print_progress) { printf STDERR "\e\x{37}"; diff --git a/t/TestFunctions.pm b/t/TestFunctions.pm index 94441ff..6c60dee 100644 --- a/t/TestFunctions.pm +++ b/t/TestFunctions.pm @@ -37,9 +37,9 @@ sub are_hardlinked { return "$dev:$ino"; }; - my $starter_ident = &$gen_ident($starter); + my $starter_ident = $gen_ident->($starter); foreach my $file (@_) { - if (&$gen_ident($file) ne $starter_ident) { + if ($gen_ident->($file) ne $starter_ident) { return 0; } } @@ -62,7 +62,7 @@ sub filemtime { sub has_mtime { my $mtime = shift; foreach my $file (@_) { - if (&filemtime($file) != $mtime) { + if (filemtime($file) != $mtime) { return 0; } } @@ -80,11 +80,11 @@ sub mktempdir { sub prep_tar { my $tarball = shift // (dirname(__FILE__) . '/t.tar'); - my $td = &mktempdir; + my $td = mktempdir(); # Note: Using chdir from Cwd automatically keeps $ENV{PWD} up-to-date (just # in case) - my $oldpwd = &getcwd; + my $oldpwd = getcwd(); chdir $td; my $tar = Archive::Tar->new; diff --git a/t/freed-bytes-commas.t b/t/freed-bytes-commas.t index fc5b13f..1ba5ac6 100644 --- a/t/freed-bytes-commas.t +++ b/t/freed-bytes-commas.t @@ -7,13 +7,13 @@ use Test::Simple use TestFunctions; -my $test_dir = &mktempdir; -&put_file( +my $test_dir = mktempdir(); +put_file( "$test_dir/1", "$test_dir/2", ); -my (undef, $stdout, $stderr) = &run_script_capture('-f', $test_dir); +my (undef, $stdout, $stderr) = run_script_capture('-f', $test_dir); ok "freed 1,048,576 bytes (1 MB)\n" eq $stderr, 'prints freed bytes with commas'; sub put_file { diff --git a/t/freed-bytes.t b/t/freed-bytes.t index 3945e3e..fabbe02 100644 --- a/t/freed-bytes.t +++ b/t/freed-bytes.t @@ -7,7 +7,7 @@ use Test::Simple use TestFunctions; -my $tarball_dir = &prep_tar; +my $tarball_dir = prep_tar(); my $test_dir = "$tarball_dir/t/freed-bytes"; my @files = ( "$test_dir/1", @@ -17,7 +17,7 @@ my @files = ( ); # Smoke test -ok !&are_hardlinked(@files), 'not hardlinked before we start'; -my (undef, $stdout, $stderr) = &run_script_capture('-f', $test_dir, $test_dir); -ok &file_exists(@files), 'files were not accidentally deleted'; +ok !are_hardlinked(@files), 'not hardlinked before we start'; +my (undef, $stdout, $stderr) = run_script_capture('-f', $test_dir, $test_dir); +ok file_exists(@files), 'files were not accidentally deleted'; ok "freed 24 bytes (24 B)\n" eq $stderr, 'prints correct number of freed bytes'; diff --git a/t/link-counting.t b/t/link-counting.t index e88b004..d2de4c8 100644 --- a/t/link-counting.t +++ b/t/link-counting.t @@ -7,7 +7,7 @@ use Test::Simple use TestFunctions; -my $tarball_dir = &prep_tar; +my $tarball_dir = prep_tar(); my $test_dir = "$tarball_dir/t/link-counting"; my @files = ( "$test_dir/most-links", @@ -15,7 +15,7 @@ my @files = ( ); # Smoke test -ok !&are_hardlinked(@files), 'not hardlinked before we start'; -&run_script($test_dir); -ok &file_exists(@files), 'files were not accidentally deleted'; -ok &are_hardlinked(@files), 'files with existing links got hardlinked'; +ok !are_hardlinked(@files), 'not hardlinked before we start'; +run_script($test_dir); +ok file_exists(@files), 'files were not accidentally deleted'; +ok are_hardlinked(@files), 'files with existing links got hardlinked'; diff --git a/t/normal-linkage.t b/t/normal-linkage.t index 1743053..9c25b82 100644 --- a/t/normal-linkage.t +++ b/t/normal-linkage.t @@ -7,7 +7,7 @@ use Test::Simple use TestFunctions; -my $tarball_dir = &prep_tar; +my $tarball_dir = prep_tar(); my $test_dir = "$tarball_dir/t/normal"; my @files = ( "$test_dir/foo/same", @@ -15,7 +15,7 @@ my @files = ( ); # Smoke test -ok !&are_hardlinked(@files), 'not hardlinked before we start'; -&run_script($test_dir); -ok &file_exists(@files), 'files were not accidentally deleted'; -ok &are_hardlinked(@files), 'files with the same contents got hardlinked'; +ok !are_hardlinked(@files), 'not hardlinked before we start'; +run_script($test_dir); +ok file_exists(@files), 'files were not accidentally deleted'; +ok are_hardlinked(@files), 'files with the same contents got hardlinked'; diff --git a/t/normal-non-linkage.t b/t/normal-non-linkage.t index afbd0f4..c9b372d 100644 --- a/t/normal-non-linkage.t +++ b/t/normal-non-linkage.t @@ -7,7 +7,7 @@ use Test::Simple use TestFunctions; -my $tarball_dir = &prep_tar; +my $tarball_dir = prep_tar(); my $test_dir = "$tarball_dir/t/normal"; my @files = ( "$test_dir/foo/same", @@ -15,7 +15,7 @@ my @files = ( ); # Smoke test -ok !&are_hardlinked(@files), 'not hardlinked before we start'; -&run_script($test_dir); -ok &file_exists(@files), 'files were not accidentally deleted'; -ok !&are_hardlinked(@files), 'files with different contents did not get hardlinked'; +ok !are_hardlinked(@files), 'not hardlinked before we start'; +run_script($test_dir); +ok file_exists(@files), 'files were not accidentally deleted'; +ok !are_hardlinked(@files), 'files with different contents did not get hardlinked'; diff --git a/t/sha1collision-non-linkage.t b/t/sha1collision-non-linkage.t index f494436..f7d8c67 100644 --- a/t/sha1collision-non-linkage.t +++ b/t/sha1collision-non-linkage.t @@ -7,7 +7,7 @@ use Test::Simple use TestFunctions; -my $tarball_dir = &prep_tar; +my $tarball_dir = prep_tar(); my $test_dir = "$tarball_dir/t/sha1-collision"; my @files = ( "$test_dir/shattered-1.pdf", @@ -15,7 +15,7 @@ my @files = ( ); # Smoke test -ok !&are_hardlinked(@files), 'not hardlinked before we start'; -&run_script($test_dir); -ok &file_exists(@files), 'files were not accidentally deleted'; -ok !&are_hardlinked(@files), 'files with the same SHA-1 hash did not get hardlinked'; +ok !are_hardlinked(@files), 'not hardlinked before we start'; +run_script($test_dir); +ok file_exists(@files), 'files were not accidentally deleted'; +ok !are_hardlinked(@files), 'files with the same SHA-1 hash did not get hardlinked'; diff --git a/t/timestamp-preservation.t b/t/timestamp-preservation.t index c8eea03..09be7a8 100644 --- a/t/timestamp-preservation.t +++ b/t/timestamp-preservation.t @@ -7,7 +7,7 @@ use Test::Simple use TestFunctions; -my $tarball_dir = &prep_tar; +my $tarball_dir = prep_tar(); my $test_dir = "$tarball_dir/t/timestamp-preservation"; my @files = ( "$test_dir/newer-more-linked", @@ -15,9 +15,9 @@ my @files = ( ); # Smoke test -ok !&are_hardlinked(@files), 'not hardlinked before we start'; -my $should_have_mtime = &filemtime($files[1]); -&run_script($test_dir); -ok &file_exists(@files), 'files were not accidentally deleted'; -ok &are_hardlinked(@files); -ok &has_mtime($should_have_mtime, @files), 'timestamps updated to use oldest'; +ok !are_hardlinked(@files), 'not hardlinked before we start'; +my $should_have_mtime = filemtime($files[1]); +run_script($test_dir); +ok file_exists(@files), 'files were not accidentally deleted'; +ok are_hardlinked(@files); +ok has_mtime($should_have_mtime, @files), 'timestamps updated to use oldest'; diff --git a/t/zero-size-non-linkage.t b/t/zero-size-non-linkage.t index 1f841fd..b4c4257 100644 --- a/t/zero-size-non-linkage.t +++ b/t/zero-size-non-linkage.t @@ -7,7 +7,7 @@ use Test::Simple use TestFunctions; -my $tarball_dir = &prep_tar; +my $tarball_dir = prep_tar(); my $test_dir = "$tarball_dir/t/zero-size"; my @files = ( "$test_dir/empty1", @@ -15,7 +15,7 @@ my @files = ( ); # Smoke test -ok !&are_hardlinked(@files), 'not hardlinked before we start'; -&run_script($test_dir); -ok &file_exists(@files), 'files were not accidentally deleted'; -ok !&are_hardlinked(@files), 'zero-sized files did not get hardlinked'; +ok !are_hardlinked(@files), 'not hardlinked before we start'; +run_script($test_dir); +ok file_exists(@files), 'files were not accidentally deleted'; +ok !are_hardlinked(@files), 'zero-sized files did not get hardlinked';