From fbd2151e74bdac26f629b33681c11d37edacd7a0 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 18 Oct 2012 09:18:35 -0700 Subject: Add scripts/find-filename --- scripts/find-filename | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 scripts/find-filename diff --git a/scripts/find-filename b/scripts/find-filename new file mode 100755 index 00000000..c9b09680 --- /dev/null +++ b/scripts/find-filename @@ -0,0 +1,45 @@ +#!/usr/bin/perl -w + +use strict; + +open(FH, $ARGV[0]); +my $search = $ARGV[1]; + +my $line; +my $is_indexed; +my $filename; +my @buf = (); +my $dump = 0; + +while ( $line = ) { + + chomp($line); + + if ( $line =~ /^-----\ Begin chunk\ -----$/ ) { + $dump = 0; + @buf = (); + } + + if ( $dump == 1 ) { + printf("%s\n", $line); + } elsif ( $dump == 0 ) { + push(@buf, $line); + } + + if ( $line =~ /^Image\ filename: (.*)$/ ) { + $filename = $1; + if ( $filename eq $search ) { + while ( my $l = shift(@buf) ) { + printf("%s\n", $l); + } + $dump = 1; + } else { + $dump = -1; + } + } + + if ( $line =~ /^-----\ End chunk\ -----$/ ) { + + } + +} -- cgit v1.2.3