print "#! perl -w use strict; my $infile = 'c:/doclist.chr'; my $outfile = 'c:/doclist.txt'; #use File::Find; #use File::Copy cp; open IN, "<$infile" or die "Couldn't open $infile, $!"; open OUT,">$outfile" or die "Couldn't open $outfile, $!"; ## print OUT join '|', split /,/ while ; while() { chomp; my @fields = split /,/; my $string1 = $fields[6]; do { warn "Empty field 7"; next } unless $string1; # this will keep the first 24 chars of string, throw out the rest and # then append H:\ to it. # need \\ here or it won't compile my $string_header = $string1; substr($string_header,0,24) = 'H:'; # this will return :\ as we get 2 chars LEN from pos 25 my $string2 = substr($string1,26,2); # this will set $string3 to the last 13 chars of the string my $string3 = substr($string1,-13); my $finstring = $string_header.$string2.$string3; my $out = join '|', @fields[0..5], $finstring, "\n"; print OUT $out; } exit; \n";