An annoying Ruby "gotcha"

If you run this on a system where /usr/bin/ruby is ruby1.6 you'll get a line containing "x" for each line in /etc/passwd. On a system where /usr/bin/ruby is ruby1.8 you'll get a single line containing "x".

`cat /etc/passwd`.split('\n').each() {

Why? Because they interpret the split('\n') differently.

This has caught me out quite a bit, because Mac OS 10.3 has ruby1.6 while Debian testing/unstable has ruby1.8 and I use both systems regularly.

I'm not sure what lesson or lessons I should learn from this. Always specify the version of the interpreter you've tested with? Stop assuming Ruby's any less strange than Perl? Give in and learn Python too, and see if that's any better? Stop complaining when Sun won't change something that's obviously broken, for fear of breaking existing code?