Peter Corlett > Acme-Globule-0.003 > Acme::Globule::Range

Download:
Acme-Globule-0.003.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Source  

NAME ^

Acme::Globule::Range - alternative range operator

SYNOPSIS ^

 use Acme::Globule qw( Range );

 foreach (<10..1>) {
   print "$_... ";
 }
 print "Lift-off!\n";

 # put down that crack pipe...
 sub my_keys(\%) {
   my @hash = %{ $_[0] };
  return @hash[ glob("0,2..$#hash") ];
 }

 sub my_values(\%) {
   my @hash = %{ $_[0] };
  return @hash[ glob("1,3..$#hash") ];
 }

DESCRIPTION ^

This is a Acme::Globule plugin that makes glob() do range operations. The following range formats are supported:

A..Z

Returns the integers between A and Z. If Z is lower than A, this will return a reversed range. Thus <1..9> is (1..9) and <9..1> is (reverse 1..9).

A,B..Z

Returns the integers between A and Z with a step such that the second value is B. Thus <1,3..9> is (1, 3, 5, 7, 9).

A..Y,Z

Returns the integers between A and Z with a step such that the next to last value is Y. Thus <1..7,9> is (1, 3, 5, 7, 9).

Any other string will fall through to the next plugin.

BUGS ^

The syntax is rather rigid.

SEE ALSO ^

List::Maker which supports a wider range (*groan*) of syntax but affects glob() globally.

AUTHOR ^

All code and documentation by Peter Corlett <abuse@cabal.org.uk>.

COPYRIGHT ^

Copyright (C) 2008 Peter Corlett <abuse@cabal.org.uk>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SUPPORT / WARRANTY ^

This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.