A few weeks ago a friend of mine, who is a Ruby programmer that has to write Perl for $job, said "Perl makes me cry". He gave specific examples, one was...
Perl: my ($self) = @_; push @{ $test_files{ident $self} } , @failure_files;
Ruby: @test_files.push(*failure_files)
I feel like perl is actively resisting me here.
use autobox; use autobox::Core;
$test_files{ident $self}->push(@failure_files);
You might also want to take a look at Moose::Autobox. It has a different goal from autobox::Core, which is to be more like the proposed core types and methods for Perl 6 (mostly found in Syn 29). And as far as your ruby-friend is concerned, you might want to show him Moose itself, he might not miss ruby as much.
- Stevan
push @{ $self->{'files'} }, @more_files;
Re:Class:Std
Aristotle on 2007-10-16T00:30:45
Throwing in an extra arrow makes it look simpler? Strange definition of simpler.
:-) I like to preface my inside-out object methods with “
my $this = ident my $self = shift;
”, btw, which makes that code into this:push @{ $test_files{ $this } } , @failure_files;Of course Hash::Util::FieldHash’s
idhash
function will make that separate$this
unnecessary in 5.10 and you’ll be able to just write this:push @{ $test_files{ $self } } , @failure_files;The real problem persists through all of these, though: that extra
@{}
bracket.Re:Class:Std
perrin on 2007-10-16T01:05:08
To each their own, I guess. The @{} doesn't bother me at all, but the way instance variables are referenced in Class::Std does.Re:Class:Std
Aristotle on 2007-10-16T02:04:41
My reply swelled into a post of its own.