Why do most computer languages assign variables to the left? x86 assembly and COBOL both mov* or MOVE to assign to the right, but those are the only ones I know.

But I kind of like assign to the right, because of two things: (1) I always start with something I know, and (2) I type from left to right. This means that I should at least try giving rightward assignment a chance. But, that means writing COBOL, right?

Well, not if you use perl's Filter::Simple for a little odyssey.... ;)

use IO::File; use warnings; use strict; use right; 2.718281828 = my $var ; $var . "\n" | print ; IO::File->new('/etc/passwd')->getlines | map { (split(/:/))[0] } | grep { /nobody/ and printf("saw nobody\n") } ;

A basic filter setup for this is:

package right; use Filter::Simple; our $DEBUG = 1; FILTER_ONLY code => sub { s/\n//g; my @result; my @lines = split /\;/, $_; for my $l (@lines) { # is there an equate? get it out of the way my $end; $l =~ /(.*) = (.*)/ and do { $end = $2; $l = $1; }; # any pipes? reverse 'em $l =~ / \| / and do { my @p = split / \| /, $l; $l = join ' ', reverse @p; }; # if we had an equate, fix it $end ne "" and $l = $end . ' = ' . $l; push(@result, $l); } $_ = join ';', @result, ''; }, all => sub { $DEBUG and print }; 1;

I've never mucked around with Parse::RecDescent, but this gives me a reason as the above is quick to code but most certainly insufficient.


Heh, Nice! Just a heads up, bloglines doesn't preserve the code formatting...which reminds me I need to check my feed...hrm - Nathan