Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hey folks, I have two pricing structures that I need to add to a price file prep process that I run in Perl. It seems like a perfectly simple thing to do, but I must not understand true and false like I should. In this price file there are around 150,000 lines and I am only interested in 4 of the columns in the tab delimited file. Those columns are the part number, part description, company 1 price, company 2 price. Here is the code:
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"; }
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.

In reply to Something is defined when it shouldn't be? by tnyflmngs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-19 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found