On 09/09/2011 09:54, Chris Stinemetz wrote:

What would be the best way to omit any record when varible $dist is
null or not>    1 ?

But from your code, I assume you mean to omit records when the _length_
of $dist isn't greater than one?

I would make the check immediately $dest is assigned, and 'next' over
the record in the same way as you do for those that contain no semicolon.

  my($cell,$sect,$chan,$rlp1,$rlp2,$rlp3,$rlp4,$dist) =
      @data[31,32,38,44,45,46,47,261];

  next unless length $data>  1;

and then later on, you know $dist is valid so there is no need for the
test when you are reformatting it:

  $dist = sprintf "%.1f", $dist/8/6.6/2;

HTH,

Rob


Thank you Rob. Your advise worked perfectly.
One more question. Is it possible to combine the three next if
statements below? So the code if doesn't take 3 lines?

          next if(length($dist) == 0);
          next if(length($cell) == 0);
          next if(length($sect) == 0);

If '0' is an invalid value for all three variables then you could write

  next unless $dist and $cell and $sect;

or if you want to check only the length

  next unless length $dist and length $cell and length $sect;

Rob

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to