in reply to Re: "not grep iterator" error
in thread "not grep iterator" error

You're right, that does work. However, the reason I was using \@ in my prototype was so that I could modify the list. Copying into and then dereferencing a new list defeats the purpose. What I have ended up doing is using a prototype like this
sub subby(&\@@)
Then, I can modify the first list (but only pass it in as @list) and for the second list, I can use grep and friends to produce it, which suits my needs. Thanks

Replies are listed 'Best First'.
Re^3: "not grep iterator" error
by ikegami (Patriarch) on Sep 09, 2009 at 22:11 UTC

    From what you've said, your function takes a callback and two list, modifies the elements of both lists and returns a third list. Your function is insane.

    ( No, I misunderstood. It only modifies the first array which makes the rest of this post moot. The function is still pretty crazy, though )

    Anyway, you seem to be asking how to create an array of aliases. It's actually possible with little work!

    sub foo(\@) { my ($array) = @_; $_ = uc($_) for @$array; } my @array = qw( foo bar Foo Bar ); foo @{ sub { \@_ }->( grep /^[A-Z]/, @array ) }; print "$_\n" for @array;
    foo bar FOO BAR

    Of course, an array wouldn't normally be used at all.

    sub foo { $_ = uc($_) for @_; } my @array = qw( foo bar Foo Bar ); foo grep /^[A-Z]/, @array; print "$_\n" for @array;
    foo bar FOO BAR