diff options
author | Matthew Lemon <y@yulqen.org> | 2024-05-25 22:10:42 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-05-25 22:10:42 +0100 |
commit | 4cf19272e02304361a6f4bfe7c9d1a717859954f (patch) | |
tree | 8a99318a21a1e1f46f76131ab0f49f8dcb4c23e0 /unarchive.pl | |
parent | 6f09b154b168876129324349ced6cd0fa32d8213 (diff) | |
parent | 0bc7ce1ef512361f3bc0cd63b7e311204b48fa66 (diff) |
Merge branch 'master' of ssh://git.yulqen.org:2222/home/git/repositories/perl/perlscripts
Diffstat (limited to 'unarchive.pl')
-rwxr-xr-x | unarchive.pl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/unarchive.pl b/unarchive.pl new file mode 100755 index 0000000..810b008 --- /dev/null +++ b/unarchive.pl @@ -0,0 +1,39 @@ +#!/usr/bin/env -S perl + +use strict; +use warnings; +use feature q(say); +use Archive::Tar; + +# This is just a test script to play with the Archive::Tar package + +# Specify the archive file you want to read +my $archive_file = 'journal_archive_aug23.tgz'; + +# Create an Archive::Tar object for reading +my $tar = Archive::Tar->new; + +# Read the archive file +$tar->read($archive_file); + +# Search string +my $search_string = "Joanna"; + +# Iterate through the files in the archive in memory +foreach my $file ($tar->get_files) { + # Check if the file matches your filter (e.g., .txt extension) + if ($file->name =~ /\.md$/) { + # Get the content of the file and process it as needed + my $file_content = $file->get_content; + + # Perform your desired operations on $file_content + # For example, you can print it or manipulate it here + + my @lines = split(/\n/, $file_content); + foreach my $line (@lines) { + if ($line =~ /$search_string/) { + print "File name: " . $file->name . ": " . $line . "\n"; + } + } + } +} |