#!/pw/prod/svr4/bin/perl use warnings; use strict; use Data::Dumper; # # Purpose: Remove fields from emtoc file to facilitate title compare. # # I/O: # Input: Complete Emtoc text file. # Output: Emtoc file with index info missing. # # History: # 01/23/09 - Created # my $FALSE = 0; my $TRUE = 1; my $debug = $FALSE; if ( $#ARGV < 0 ) { print "Usage: $0 [In File][Out File]\n"; exit(1); } my $emtocin = $ARGV[0]; my $emtocout = $ARGV[1] || 'cmpemtocout.txt'; # begin processing open( FDIN, $emtocin ) || die "Could not open $emtocin\n"; open( FDOUT, $emtocout ) || die "Could not open $emtocout\n"; while ( my $record = <FDIN> ) { print "Record is $record\n" if $debug; # # seperate fields according to the template my @fld = split("|", $record ); # # open output file and overwrite file my $outrecord = join( '|', $fld[0], $fld[3], $fld[4], $fld[5], $fld[6], $fld[7], $fld[8] +); print FDOUT "$outrecord\n"; } close FDIN; close FDOUT; print "End of $0\n";
Input Data
file-101.pdf|BOOKMARK|4.2.5.4|71-00-03 Testing/Operating Limits|Goto_V +iew_External|FIT_WIDTH|1|N/A file-102.pdf|BOOKMARK|4.2.5.5|71-00-05 Storage/Transport|Goto_View_Ext +ernal|FIT_WIDTH|1|N/A file-103.pdf|BOOKMARK|4.2.5.6|71-00-10 Component Replacement|Goto_View +_External|FIT_WIDTH|1|N/A file-104.pdf|BOOKMARK|4.2.5.6.1|LIST OF EFFECTIVE PAGES|Goto_View_Exte +rnal|FIT_WIDTH|1|N/A file-105.pdf|BOOKMARK|4.2.5.6.2|HIGHLIGHTS|Goto_View_External|FIT_WIDT +H|1|N/A file-106.pdf|BOOKMARK|4.2.5.6.3|TABLE OF CONTENTS|Goto_View_External|F +IT_WIDTH|1|N/A
Output Results
f|e|-|1|0|1|. f|e|-|1|0|2|. f|e|-|1|0|3|. f|e|-|1|0|4|. f|e|-|1|0|5|. f|e|-|1|0|6|.
Any help would be greatly appreciated
In reply to Problem with split using a | seperator by Grey Fox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |