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;
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);
next unless length( $dist ) && length( $cell ) && length( $sect );
And if you know that $dist or $cell or $sect will never contain the
string "0" then you could write:
next unless $dist && $cell && $sect;
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/