Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

number::range(3pm) [debian man page]

Number::Range(3pm)					User Contributed Perl Documentation					Number::Range(3pm)

NAME
Number::Range - Perl extension defining ranges of numbers and testing if a number is found in the range. You can also add and delete from this range. SYNOPSIS
use Number::Range; my $range = Number::Range->new("-10..10,12,100..120"); if ($range->inrange("13")) { print "In range "; } else { print "Not in range "; } $range->addrange("200..300"); $range->delrange("250..255"); my $format = $range->range; # $format will be '-10..10,12,100..120,200..249,256..300' DESCRIPTION
Number::Range will take a description of a range, and then allow you to test on if a number falls within the range. You can also add and delete from the range. RANGE FORMAT The format used for range is pretty straight forward. To separate sections of ranges it uses a "," or whitespace. To create the range, it uses ".." to do this, much like Perl's own binary ".." range operator in list context. METHODS new $range = Number::Range->new("10..20","25..30"); Creates the range object. It will accept any number of ranges as its input. addrange $range->addrange("22"); This will also take any number of ranges as input and add them to the existing range. delrange $range->delrange("10"); This will also take any number of ranges as input and delete them from the existing range. inrange $range->inrange("26"); my @results = $range->inrange("27","200"); This will take one or more numbers and check if each of them exists in the range. If passed a list, and in array context, it will return a list of 0's or 1's, depending if that one was true or false in the list position. If in scalar context, it will return a single 1 if all are true, or a single 0 if one of them failed. range $format = $range->range; @numbers = $range->range; Depending on context this will return either an array of all the numbers found in the range, for list context. For scalar context it will return a range string. size $size = $range->size; This will return the total number of entries in the range. EXPORT None by default. SEE ALSO
Number::Tolerant, Tie::RangeHash, and Array::IntSpan for similar modules. AUTHOR
Larry Shatzer, Jr., <larrysh@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2004-12 by Larry Shatzer, Jr. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-20 Number::Range(3pm)

Check Out this Related Man Page

Bio::Range(3pm) 					User Contributed Perl Documentation					   Bio::Range(3pm)

NAME
Bio::Range - Pure perl RangeI implementation SYNOPSIS
$range = Bio::Range->new(-start=>10, -end=>30, -strand=>+1); $r2 = Bio::Range->new(-start=>15, -end=>200, -strand=>+1); print join(', ', $range->union($r2)), " "; print join(', ', $range->intersection($r2)), " "; print $range->overlaps($r2), " "; print $range->contains($r2), " "; DESCRIPTION
This provides a pure perl implementation of the BioPerl range interface. Ranges are modeled as having (start, end, length, strand). They use Bio-coordinates - all points >= start and <= end are within the range. End is always greater-than or equal-to start, and length is greather than or equal to 1. The behaviour of a range is undefined if ranges with negative numbers or zero are used. So, in summary: length = end - start + 1 end >= start strand = (-1 | 0 | +1) FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Heikki Lehvaslaiho Email heikki-at-bioperl-dot-org APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ Constructors new Title : new Usage : $range = Bio::Range->new(-start => 100, -end=> 200, -strand = +1); Function: generates a new Bio::Range Returns : a new range Args : -strand (defaults to 0) and any two of (-start, -end, -length), the third will be calculated unions Title : unions Usage : @unions = Bio::Range->unions(@ranges); Function: generate a list of non-intersecting Bio::Range objects from a list of Bio::Range objects which may intersect Returns : a list of Bio::Range objects Args : a list of Bio::Range objects Member variable access These methods let you get at and set the member variables start Title : start Function : return or set the start co-ordinate Example : $s = $range->start(); $range->start(7); Returns : the value of the start co-ordinate Args : optionally, the new start co-ordinate Overrides: Bio::RangeI::start end Title : end Function : return or set the end co-ordinate Example : $e = $range->end(); $range->end(2000); Returns : the value of the end co-ordinate Args : optionally, the new end co-ordinate Overrides: Bio::RangeI::end strand Title : strand Function : return or set the strandedness Example : $st = $range->strand(); $range->strand(-1); Returns : the value of the strandedness (-1, 0 or 1) Args : optionally, the new strand - (-1, 0, 1) or (-, ., +). Overrides: Bio::RangeI::strand length Title : length Function : returns the length of this range Example : $length = $range->length(); Returns : the length of this range, equal to end - start + 1 Args : if you attempt to set the length an exception will be thrown Overrides: Bio::RangeI::Length toString Title : toString Function: stringifies this range Example : print $range->toString(), " "; Returns : a string representation of this range Boolean Methods These methods return true or false. $range->overlaps($otherRange) && print "Ranges overlap "; overlaps Title : overlaps Usage : if($r1->overlaps($r2)) { do stuff } Function : tests if $r2 overlaps $r1 Args : a range to test for overlap with Returns : true if the ranges overlap, false otherwise Inherited: Bio::RangeI contains Title : contains Usage : if($r1->contains($r2) { do stuff } Function : tests whether $r1 totally contains $r2 Args : a range to test for being contained Returns : true if the argument is totally contained within this range Inherited: Bio::RangeI equals Title : equals Usage : if($r1->equals($r2)) Function : test whether $r1 has the same start, end, length as $r2 Args : a range to test for equality Returns : true if they are describing the same range Inherited: Bio::RangeI Geometrical methods These methods do things to the geometry of ranges, and return triplets (start, end, strand) from which new ranges could be built. intersection Title : intersection Usage : ($start, $stop, $strand) = $r1->intersection($r2) Function : gives the range that is contained by both ranges Args : a range to compare this one to Returns : nothing if they do not overlap, or the range that they do overlap Inherited: Bio::RangeI::intersection union Title : union Usage : ($start, $stop, $strand) = $r1->union($r2); : ($start, $stop, $strand) = Bio::Range->union(@ranges); Function : finds the minimal range that contains all of the ranges Args : a range or list of ranges Returns : the range containing all of the ranges Inherited: Bio::RangeI::union perl v5.14.2 2012-03-02 Bio::Range(3pm)
Man Page