NAME
Tie::Diamond - Iterate the diamond operator via a Perl array
VERSION
version 0.02
SYNOPSIS
use Tie::Diamond;
tie my(@ary), "Tie::Diamond" or die;
while (my ($idx, $item) = each @ary) {
...
}
DESCRIPTION
This module lets you iterate the diamond operator via a Perl array. Currently the only useful thing you can do with the array is just iterate it using each(), as shown in Synopsis.
The array backend does not slurp all lines into memory (or store past lines at all, actually), so it's safe to iterate over gigantic input.
FAQ
Why?
So you can treat the diamond operator as an array. One of my modules, Data::Unixish, uses this. A function can be passed a real array (to iterate over a Perl array), or a tied array (to iterate lines from STDIN or files mentioned in arguments); they don't have to change their iteration syntax.
Can I do this?
@other = @ary; # or print @ary
Currently no. But since you are slurping all lines anyway, you might as well just do:
@other = <>; # or print <>
SEE ALSO
AUTHOR
Steven Haryanto <stevenharyanto@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.