Albeit I concur mostly with FunkyMonk, just for the sake of completeness and something to play with (not everything here presented is a solution, and not even suitable sometimes (some of it is intentionally flawed - one should examine the output before using it); it tries to illustrate to a certain extent what is possible by using map):
#!/usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); { list_dump(sub { map { $_->[0] < 5 } @{set()} } ); list_dump(sub { map { $_->[2] < 5 ? $_ : () } @{set()} } ); list_dump(sub { map { [ map { $_ + 1 } @$_ ] } @{set()} } ); list_dump(sub { map { local $_ = $_; $_->[0] = 7; $_ } @{set()} } ); list_dump(sub { map { my @copy = @$_; [ map { $_ *= 2 } @copy ] +} @{set()} } ); sub list_dump (&) { my @list = $_[0]->(); print Dumper \@list; } sub set { return [ [1,2,3],[4,5,6] ]; } }
In reply to Re: AoA Selective Element Substitution
by shigetsu
in thread AoA Selective Element Substitution
by awohld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |