So how about this as an alternative?:
#!/usr/bin/perl -l sub revlist { my @list = @_; sub { pop @list }; } my $foo = revlist(@ARGV); print while local $_ = $foo->();
Edit: Optionally, closure subroutine might look like this, of course:
sub { return unless @list; pop @list; };
|
- apotheon
CopyWrite Chad Perrin |
In reply to Re^3: list reversal closure
by apotheon
in thread list reversal closure
by apotheon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |