Ruby implementation of Perl's chained expressions