From: James Edward Gray II Date: 2004-09-16T22:44:40+09:00 Subject: Re: Ex-Perl coders: Howz it feel to convert to Ruby? On Sep 16, 2004, at 12:34 AM, Michael Geary wrote: > I don't need convincing, but I'd be interested in seeing the > equivalent Perl > code just for the sake of comparison. I find it educational to see how > different languages approach a problem. #!/usr/bin/perl use strict; use warnings; package Foo; sub new { my $class = shift; my %object = ( bar => "default", boat => "values", @_ ); return bless \%object, $class; } sub bar { return shift->{bar}; } sub boat { return shift->{boat}; } sub concat { my $self = shift; return $self->{bar} . $self->{boat}; } package main; my $foo = Foo->new(bar => "bar", boat => "boat"); print $foo->concat, "\n"; print $foo->bar, "\n"; print $foo->boat, "\n"; # minor example of code difference $foo->{bar} = "Not Private!"; print "\n", $foo->bar, "\n"; __END__ Hope that helps. James Edward Gray II