diff options
author | Thomas White <taw@physics.org> | 2012-10-18 09:18:35 -0700 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-10-18 09:18:35 -0700 |
commit | fbd2151e74bdac26f629b33681c11d37edacd7a0 (patch) | |
tree | 164f52036b25ed85aa4c3f5a8574dd19ebca6eab | |
parent | 4336565ec1abdbec00e0afe7b679cf554aa66903 (diff) |
Add scripts/find-filename
-rwxr-xr-x | scripts/find-filename | 45 |
1 files changed, 45 insertions, 0 deletions
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 = <FH> ) { + + 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\ -----$/ ) { + + } + +} |