💾 Archived View for sdf.org › netsplit › perl.gmi captured on 2024-05-12 at 15:14:21. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-05-10)
-=-=-=-=-=-=-
Just for fun.
I've always thought that code being line-based was a waste of vertical space. With that in mind, here is my new and improved programming language, Horizontal Perl.
Here is the interpreter. Excuse the heretical line-based code.
#!/usr/bin/env perl use strict; use warnings; my $filename = $ARGV[0]; open my $fh, '<:unix', $filename or die "Couldn't open $filename: $!"; my $code = do { local $/; <$fh> }; close $fh; my @cols; foreach my $line (split /\n/, $code) { my @chars = split //, $line; for (my $i = 0; $i < scalar @chars; $i++) { push @{$cols[$i]}, $chars[$i]; } } my $codeblock = ''; foreach my $c (@cols) { my $statement = join '', @{$c}; unless ($statement =~ /^\s+$/) { $codeblock .= $statement . "\n"; } } eval $codeblock;
Save it as "matrix.pl" and pass it .matrix files as its only argument, such as the following:
#s s u a cb y o ( ms " ma h ey e m n l y t{ l sp o $ s r " n a ai ) a y rn ; m ( et e " ( s w vs a = e eh y l ri ( < c tf " S o it w T m c, h D e a" a I , l\ t N n > $ " i ; n ) s a } m y e o ! u " r ) ; n a m e ? " ) ;
In order to write your own .matrix scripts, the following tips may be useful:
If you've written your own .matrix script and have suggestions for improvements or want it featured on this page, e-mail me at netsplit@sdf.org.