Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <a href="http://search.cpan.org/perldoc/Archive::Tar" rel="nofollow noreferrer"><code>Archive::Tar</code></a> and <a href="http://perldoc.perl.org/File/Find.html" rel="nofollow noreferrer"><code>File::Find</code></a> modules will be helpful. A basic example is shown below. It just prints information about the files in a tar and the files in a directory tree.</p> <p>It was not clear from your question how you want to compare the files. If you need to compare the actual content, the <code>get_content()</code> method in <code>Archive::Tar::File</code> will likely be needed. If a simpler comparison is adequate (for example, name, size, and mtime), you won't need much more than methods used in the example below.</p> <pre><code>#!/usr/bin/perl use strict; use warnings; # A utility function to display our results. sub Print_file_info { print map("$_\n", @_), "\n"; } # Print some basic information about files in a tar. use Archive::Tar qw(); my $tar_file = 'some_tar_file.tar.gz'; my $tar = Archive::Tar-&gt;new($tar_file); for my $ft ( $tar-&gt;get_files ){ # The variable $ft is an Archive::Tar::File object. Print_file_info( $ft-&gt;name, $ft-&gt;is_file ? 'file' : 'other', $ft-&gt;size, $ft-&gt;mtime, ); } # Print some basic information about files in a directory tree. use File::Find; my $dir_name = 'some_directory'; my @files; find(sub {push @files, $File::Find::name}, $dir_name); Print_file_info( $_, -f $_ ? 'file' : 'other', -s, (stat)[9], ) for @files; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload