#! /usr/bin/perl -w use strict; =head1 Notices Originally developed for Perforce by VIZIM (www.vizim.com) Copyright (c) 2014 Perforce Software, Inc. and VIZIM Worldwide, Inc. All rights reserved. Please see LICENSE.txt in top-level folder of this distribution for license information =cut use v5.14.0; # Earliest version testing was performed against my $APPName = 'rawList.pl'; my $APPWHAT = 'raw file item lister; version 1.01'; my $APPNOTICES = "Copyright (c) 2014 Perforce Software, Inc. and VIZIM Worldwide, Inc. All rights reserved. See LICENSE.txt for license information."; =head1 raw file item lister Tool to list items from a raw or item file. Primary use is to isolate a single entry from a larger raw or item file for analysis. By default, a TFSEXTRACT header tag is copied to the output. Copy of this tag can be suppressed with the -n option. =cut if( defined $ARGV[0] && (uc $ARGV[0] eq '-V') ) { print "$APPWHAT\n"; exit(0); } if( ! defined $ARGV[0] || $ARGV[0] =~ m!^\-+[hH\?]! ) { print "$APPWHAT $APPNOTICES Usage: $APPName -V $APPName [-h|-?] $APPName [-n] RAW first [last] -n - no listing of TFSEXTRACT tag.\n"; exit( 0 ); } my $listHeader = 1; if( $ARGV[0] =~ m!^\-+[n]! ) { $listHeader = 0; shift @ARGV; } my $fileName = $ARGV[0]; die "Raw file $fileName does not exist" unless -e $fileName; shift @ARGV; my $first = $ARGV[0]; shift @ARGV; my $last = $first; $last = $ARGV[0] if defined $ARGV[0]; my $hRaw; open $hRaw, '<', $fileName or die "Can't open $fileName - $!"; my $list = 0; while(<$hRaw>) { if( m!^\ $last; $list = $1 >= $first && $1 <= $last; } print $_ if $list; $list = 0 if m!^\!; } close $hRaw;