blacksmith has asked for the wisdom of the Perl Monks concerning the following question:
I must apologize if this looks messy. I have not even begun to try to tackle the control characters yet. I just want to make sure that I can split the file up and assign the correct filenames to them. Before I forget. The beginning of each segment of the file begins with FAX#, two spaces after that begins 4 bytes that need to be the start of the filename. I hope that helps to clear up a little. Any advice (except to "just give up" 'cause that ain't happenin') would be appreciated. Blacksmith.use strict my $source = "c:/ftproot/$report"; my $fil_count = 0; my $delim = 'FAX#'; open IN, "c:/ftproot/$report" or die "Can't open $report: $!\n"; open OUT, ">$filename" or die "Can't write to $filename: $!\n"; while (<IN>) { if (/^(.*?)$delim(.*)$/) { seek (OUT,2,1); read (OUT, my $num,4); my $fax = join("",$num,"F",$fil_count,".txt"); my $apollo="c:/reports/$fax"; my $daym=(localtime(time()))[3]; my $afis3="c:/afis3too/$daym/$fax"; print OUT $1 if $1; foreach my $dest ($truth, $afis3, $apollo,$zenos, $faxarc) { copy (<IN>, $dest); } close OUT; $fil_count++; open OUT, "> $filename" . $fil_count . ".txt" or die "Can't write to out${fil_count}.txt: $!\n"; print OUT $2 if $2; } else { print OUT $_; } } close IN; close OUTPUT; unlink $source;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Segmenting a file &deleting control characters
by bikeNomad (Priest) on Jun 19, 2001 at 21:46 UTC | |
|
Re: Segmenting a file &deleting control characters
by Anonymous Monk on Jun 19, 2001 at 23:59 UTC | |
by blacksmith (Hermit) on Jun 20, 2001 at 00:04 UTC |