comparison bin/shove @ 2026:d0780f04e9c7

<oerjan> mv shove bin/shove
author HackBot
date Thu, 07 Feb 2013 00:11:19 +0000
parents 99dfa6a18c7f
children
comparison
equal deleted inserted replaced
2025:ed854c3bcf55 2026:d0780f04e9c7
16 use strict; 16 use strict;
17 17
18 # Read in the program 18 # Read in the program
19 19
20 my $debug = ($#ARGV >= 0 and $ARGV[0] eq '-d' and shift and 1); 20 my $debug = ($#ARGV >= 0 and $ARGV[0] eq '-d' and shift and 1);
21 my @program = ($#ARGV >= 0) ? @ARGV : <>; 21 my @program = ($#ARGV >= 0 and ($ARGV[0] ne '-f' or (shift and 0)))
22 ? @ARGV : <>;
22 chomp for @program; 23 chomp for @program;
23 24
24 my $x = 0; 25 my $x = 0;
25 my $y = 0; 26 my $y = 0;
26 my $width = 0; $width = ($width < length $_ ? length $_ : $width) for @program; 27 my $width = 0; $width = ($width < length $_ ? length $_ : $width) for @program;
107 print "{$_} " for @stack; 108 print "{$_} " for @stack;
108 print "\n"; 109 print "\n";
109 print "$_\n" for @program; 110 print "$_\n" for @program;
110 substr $program[$y], $x, 1, $c; 111 substr $program[$y], $x, 1, $c;
111 rotateprogram $tr; 112 rotateprogram $tr;
112 scalar <>; 113 scalar <STDIN>;
113 } 114 }
114 115
115 while ($x < $width && $y < $height && $x >= 0 && $y >= 0) { 116 while ($x < $width && $y < $height && $x >= 0 && $y >= 0) {
116 showprogram if $debug; 117 showprogram if $debug;
117 my $cmd = substr $program[$y], $x, 1; 118 my $cmd = substr $program[$y], $x, 1;