Nordic Perl Workshop 2007

About
  What
  When
  Where
Information
  Call for Papers
  Sponsorship
  Presskit
  Wiki
Register
  Log in
Users
  Search
  Statistics
Presentations
  Favorite Talks
  Schedule
  iCal export
  Submit a talk proposal
Previous workshops
  NPW 2006
  NPW 2005
  NPW 2004
  SPW 2003
Related conferences
 Perl Toolchain Summit 2024
 London Perl & Raku Workshop 2024

Array::Slice - context-dependent array iterator

By Dmitry Karasik (‎McFist‎) from Copenhagen.pm
Lightning talk
Language:


I've always wanted the power of foreach(@arr) to be applied to arrays working with more than one item at a time. Perl6 does it, Perl5 with source filtering can do it, close, but no cigar. This module is an small step towards the idea, an attempt to produce a way of slicing a single array with least obtrusive syntax I can think of. Now, you can iterate over an array assigning several items per cycle, by

three items at once:

while ( my ( $x, $y, $z) = slice @arr) { ... }

or two,

while ( my ( undef, $second) = slice @arr) { ... }

or even forty-two:

while ( @a = slice @arr, 42) { ... }

URL: http://search.cpan.org/~karasik/Array-Slice-0.03/Slice.pm




LogicLab FULLRATE ActiveState
Adapt Code3 Stonehenge
Versed Solutions The Perl Review YEF
Sifira DKUUG
Copenhagen Perl Mongers Nordic Perl Workshop 2007 is organized by the Copenhagen Perl Mongers and made possible by our sponsors

Valid XHTML 1.0 Transitional