Created
July 30, 2019 05:07
-
-
Save alunux/9549bb38dc55aba53fa504313e37adba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use File::Basename; | |
use IO::Compress::Gzip qw(gzip $GzipError); | |
my $mypath = dirname($0); | |
my $index_fn = "$mypath/index"; | |
my @test_append = ( | |
'WIWW.2019-03-22-21-48-30.2019-03-23-09-00-00.png', | |
'WIWW.2019-03-22-21-48-30.2019-03-23-10-00-00.png', | |
'WIWW.2019-03-22-21-48-30.2019-03-23-11-00-00.png', | |
'WIWW.2019-03-22-21-48-30.2019-03-23-12-00-00.png', | |
'WIWW.2019-03-22-21-48-30.2019-03-23-13-00-00.png', | |
'WIWW.2019-03-22-21-48-30.2019-03-23-14-00-00.png', | |
); | |
open (my $fh, ">:gzip", $index_fn) or die "Could not write to $index_fn: $!"; | |
open(F, qq(aws s3 ls s3:$bucket_url | awk '{ print \$4 }' |)); | |
while (<F>) { | |
print { $fh } $_; | |
}; | |
close(F); | |
close($fh); | |
# gzip $input => $output or die "Error compressing '$input': $GzipError\n"; | |
open (my $fh, "<:gzip", $index_fn) or die "Could not read $index_fn: $!"; | |
my @found = (); | |
while(<$fh>) { | |
push(@found, $_) if /\b2018-07-30-02-00-00\b/; | |
} | |
close($fh); | |
foreach (@found) { print "$_"; } | |
open (my $fh, ">>:gzip", $index_fn) or die "Could not write to $index_fn: $!"; | |
foreach (@test_append) { | |
print { $fh } "$_\n"; | |
} | |
close($fh); | |
open (my $fh, ">>:gzip", $index_fn) or die "Could not write to $index_fn: $!"; | |
open(F, "<:gzip", "$mypath/indexx"); | |
print $fh <F>; | |
close(F); | |
close($fh); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment