Johnson, Reginald (GTI) wrote: > My code is comparing the variables node and db in one input file to > bkup_node and bkup_db in the other input file. If they match then a > line is written to the output file. While I am getting the desired > output I don't think I am doing this in the most efficient manor. When I > have the print statement turned on I see that the code is still > comparing the same node and db after a match is found. Any advice would > be appreciated.
You don't need to store both files in memory and you don't even need the whole lines of the file you do store in memory. You could do something like this: #!/usr/bin/perl use strict; use warnings; open RMANFILE, '<', "/adsm/CRONJOBS/RMAN/rman_out_temp-$today" or die "cannot open rman file: $!\n"; open LASTBKUPFILE, '<', '/adsm/CRONJOBS/RMAN/lastbkup_temp' or die "cannot open last backup file: $!\n"; open OUTFILE, '>', "/adsm/CRONJOBS/RMAN/RMANFILES/rman_out_temp-$today" or die "cannot open out file: $!\n"; my @bkupArray; while ( <LASTBKUPFILE> ) { # Only need to store three fields from '/adsm/CRONJOBS/RMAN/lastbkup_temp' push @bkupArray, [ /^([^_]+)/, ( split /,/ )[ 1, 11 ] ]; } while ( my $line = <RMANFILE> ) { chomp $line; my ( $node, $db ) = split ' ', $line; for my $bkline ( @bkupArray ) { print "node=>$node<= bkup_node=>$bkline->[0]<= db=>$db<= bkup_db=>$bkline->[1]<=\n"; if ( index( $node, $bkline->[0] ) >= 0 && index( $db, $bkline->[1] ) >= 0 ) { print OUTFILE "$line $bkline->[2]\n"; } } } __END__ John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/