comparing string with null in perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shrutisinha
    New Member
    • Feb 2007
    • 25

    comparing string with null in perl

    if (int(substr($re cord,1,8)) > int(0)||
    (substr($record ,11,16))> int(0))
    {
    if (int(substr($re cord,1,9)) >= int(100000000)) {
    $Ban = trim(substr($re cord,1,9));
    }

    if ((substr($recor d,48,8)) ne null) {

    $prd_typ = trim(substr($re cord,48,8));

    }

    this don't work as it doesn't recognise the null value, somebody please help me in this problem
    what i am trying to do isas soon as my prd_typ hit null value i want to print prev value what is in the prd_typ ..
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    there is no "null" in perl, try like this:

    if ( substr($record, 48,8) ) {

    that will return true if the substr function is able to parse $record with the arguments 48,8 so the expresion in the following block will be processed.

    Comment

    • Shrutisinha
      New Member
      • Feb 2007
      • 25

      #3
      Originally posted by KevinADC
      there is no "null" in perl, try like this:

      if ( substr($record, 48,8) ) {

      that will return true if the substr function is able to parse $record with the arguments 48,8 so the expresion in the following block will be processed.
      hi thanks kevin that helped me
      i changed the code to this and it works now
      ############### ############### ############
      ## Extracting Ban And Product Type records
      ############### ############### ############

      if (int(substr($re cord,1,8)) > int(0)||
      (substr($record ,11,16))> int(0))
      {
      if (int(substr($re cord,1,9)) >= int(100000000)) {
      $Ban = trim(substr($re cord,1,9));
      print OutPutFile $prd_typ;
      }

      if ((substr($recor d,48,8)) ne " "){

      $prd_typ = trim(substr($re cord,48,8));

      }

      Comment

      Working...