Hi Chris, thanks for not top-posting. See below for my response.
On Fri, 9 Sep 2011 03:54:14 -0500 Chris Stinemetz <chrisstinem...@gmail.com> 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); > Well, the naive way to do it would be to say: next if (!length($dist) or !length($cell) or !length($sect)); There's a better way using List::MoreUtils : use List::MoreUtils qw(any); next if (any { !length($_) } $dist, $cell, $sect); Or: use List::MoreUtils qw(notall); next if (notall { length($_) } $dist, $cell, $sect); (Queue golfing.). Hope it helps. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What does "Zionism" mean? - http://shlom.in/def-zionism My opinions may seem crazy but they all make sense. Insane sense, but sense nonetheless. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/