tnyflmngs has asked for the wisdom of the Perl Monks concerning the following question:
There are two cases I am looking for: 1. Both prices are empty or 2. Both prices are not empty. The two die statements are there for troubleshooting as is the print Dumper statement. If both prices have a price listed then I want to write the part number, part description, and price to the appropriate file for upload into the business system. The print Dumper statement prints the value of both prices as ' ' which I have visually verified, however I am entering the else block. Because of that I am writing every line to the file, which I don't want. What should I be using as a condition in the if block. Keep in mind that it is possible that a price value could look like ' 150' and the number of white space characters is unknown.my @line = split(/\t+?/, $row); my $part_number = $line[0]; my $part_desc = $line[1]; my $company1_price = $line[3]; my $company2_price = $line[5]; print Dumper $company1_price, $company2_price; if (!$company1_price && !$company2_price) { die "Entered if block\n"; #next; } else { die "Entered else block\n"; print $company1_file"$part_number\t$part_desc\t $company1_price\n"; print $company2_file "$part_number\t$part_desc\t $company2_price\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Something is defined when it shouldn't be?
by choroba (Cardinal) on Nov 30, 2012 at 22:54 UTC | |
|
Re: Something is defined when it shouldn't be?
by Kenosis (Priest) on Nov 30, 2012 at 23:34 UTC | |
|
Re: Something is defined when it shouldn't be?
by runrig (Abbot) on Dec 01, 2012 at 00:43 UTC |