Hi All,

I continue to work on my first perl program. :-)  I am stuck again and could
use your guidance.

Here is the code snippet that I am working on right now.  The problem that I
have is that when processing a size like 30" x 150'6" it sees the first
dimension as a number of feet.  How can I get perl to recognize that something
like this is implicitly 0' 30"?

#     Parse up the size string.
      if ($v_size_str =~ /[0-9]*['"][    ]*x[    ]*[0-9]*['"]/i){
#        It looks like a size string so continue to process.
#        Split the size string into its two parts.
         ($v_dim1, $v_dim2) = split(/[   ]*x[    ]*/i, $v_size_str);
#        Now split dimension one into feet and inch parts.
         my ($v_feet_str, $v_inch_str) = split(/(?:'|")/, $v_dim1);
         print "Feet:    $v_feet_str\n";
         print "Inches:  $v_inch_str\n";
#        Check for fraction in inch string.
         if ($v_inch_str =~ /\//){
#           There is a fraction to deal with.
#           Parse the fraction using whitespace or a hyphen (-)
#           and the forward slash (/) character.
            my ($v_whole_in, $v_numer, $v_denom) = split(/(?: |-|\/)/,
$v_inch_str);
            print "Whole inches:    $v_whole_in\n";
            print "Numerator:  $v_numer\n";
            print "Denominator:  $v_denom\n";
         }

Kind Regards,
Keith

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to