William Ampeh wrote:
>
> Hello,
Hello,
> This is kind of sloppy, but it is what I have been able to come up with.
> How can I make this more "cleaner"?
>
> [BIG snip]
Ok, you wanted cleaner, perhaps this will help:
#!/opt/local/bin/perl
use warnings;
use strict;
use Getopt::Std;
sub error_messages {
print <<ERROR;
E R R O R
USAGE: $0 -i {excel filename} -o {output filename }
EG: $0 -i table1a.xls -o table1a.txt
- E X E C U T I O N S U P P R E S S E D ! ! ! -
\a
ERROR
exit 1; #++ failure
}
error_messages if @ARGV < 4;
my %opts;
getopts( 'i:o:', \%opts );
error_messages unless $opts{'i'} and $opts{'o'};
my %MAIN_ADD_DECK;
my $family_head;
open my $infile, '<', $opts{'i'} or die "\aCannot open '$opts{'i'}' $!";
# ~~~~~~~~~~~ READING OF INPUT FILE BEGINS HERE ~~~~~~~~~~
while ( <$infile> ) {
$family_head = $1 if s/(f.\d{9}\..)\s*=//i;
push @{ $MAIN_ADD_DECK{$family_head} }, /(f.\d{9}\..)/ig
if $family_head;
}
close $infile;
open my $outfile, '>', $opts{'o'} or die "\aCannot open '$opts{'o'}' $!";
for my $family ( sort keys %MAIN_ADD_DECK ) {
print $outfile "$family = {@{ $MAIN_ADD_DECK{$family} }}\n";
}
close $outfile;
__END__
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]