[vox-tech] ruby (was: hold on to your hats - perl vs python)

Henry House vox-tech@lists.lugod.org
Thu, 18 Jul 2002 17:40:19 -0700


--r5Pyd7+fXNt84Ff3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jul 18, 2002 at 04:49:13PM -0700, Rod Roark wrote:
> On Thursday 18 July 2002 04:30 pm, Henry House wrote:
> > ...
> > I like writing
> >
> > 		'a b c d'.split(/\s/).each do |i|
> > 			puts "elem =3D #{i}"
> > 		end
> >
> > than
> >
> > 		foreach my $i (split(/\s/, "a b c d")) {
> > 			print "elem =3D $i\n"
> > 		}
>=20
> Actually the Perl version can be a bit more succinct:
>=20
>   for (split /\s/, "a b c d") {print "elem =3D $_\n"}

True. I consider $_ and friends to be ugliness best avoided, however. Perl
can be made plenty succinct, but usually at the cost of readability. To read
such perl code you need to keep a lot of syntax rules in your head.

Btw, the best place to learn about ruby is www.ruby-lang.org.

--=20
Henry House
The attached file is a digital signature. See <http://romana.hajhouse.org/p=
gp>
for information.  My OpenPGP key: <http://romana.hajhouse.org/hajhouse.asc>.

--r5Pyd7+fXNt84Ff3
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9N1/zKK1cAVjXujwRApwXAKDJnjuSojRn3TGmsXQFcivRNeY2EgCg4gbn
FekXZW8+7QZailI1EZWPkI8=
=2Bid
-----END PGP SIGNATURE-----

--r5Pyd7+fXNt84Ff3--