The semi-automatic doodle machine
A bit longer than most but I like it so much I had to include it.
26. January 2010
A bit longer than most but I like it so much I had to include it.
26. January 2010
#!/usr/bin/perl
print "Use a pencil and a 210mm x 210mm sheet of paper. Start with your hand at the upper-left corner.\n";
@position = ('up', 'down');
@direction = (['up', '-'], ['to the left', '-'], ['down', '+'], ['to the right', '+']);
@amount = (0, 0);
while(1){
$d = int(rand(scalar @direction));
$new_amount = int(rand(100));
unless(eval("$amount[$d%2] $direction[$d][1] $new_amount") < 0 || eval("$amount[$d%2] $direction[$d][1] $new_amount") > 210){
print "With pencil ".$position[int(rand(scalar @position))].", move ".$new_amount."mm ".$direction[$d][0].".[Enter]\n";
$amount[$d%2] = eval("$amount[$d%2] $direction[$d][1] $new_amount");
$input = <>;
}
}
Augmented reality
20. January 2010
20. January 2010
#!/usr/bin/perl $reality = "real text\n"; $augmented_reality = "\e[31;40m augmented ".$reality."\e[0m"; print $reality; print $augmented_reality;
Carcinogen
17. January 2010
17. January 2010
#!/usr/bin/perl
while(1){
$new_cell = $0;
$ts = time;
$new_cell =~ s/^(.*?)\.?([^\.]*)$/$1$ts\.$2/;
`cp $0 $new_cell`;
print `clear && df`;
sleep(1);
}
The strain and pressure of modern living
Running this for extended periods of time will cause your computer to become unresponsive.
11. January 2010
Running this for extended periods of time will cause your computer to become unresponsive.
11. January 2010
#!/usr/bin/perl
while(1){
my $strain = {name => 'strain'};
my $pressure = {name => 'pressure'};
$strain->{strain} = $pressure;
$pressure->{pressure} = $strain;
select(undef, undef, undef, 0.0002);
print `clear && free -m`;
}
Substance trilogy - Gas
10. December 2009
10. December 2009
#!/usr/bin/perl
sub match { print "match\n"; }
if(<> =~ /^.+$/){
match;
}
Substance trilogy - Fluid
10. December 2009
10. December 2009
#!/usr/bin/perl
sub match { print "match\n"; }
$in = <>;
if($in =~ /$in/){
match;
}
Substance trilogy - Solid
10. December 2009
10. December 2009
#!/usr/bin/perl
sub match { print "match\n"; }
if(<> =~ /^solid$/){
match;
}
WAR has NO value
18. November 2009
18. November 2009
#!/usr/bin/perl use constant WAR; print WAR;
If times ten
17. November 2009
17. November 2009
#!/usr/bin/perl
$one = 1;
if($one){
$two = 1;
if($two){
$three = 1;
if($three){
$four = 1;
if($four){
$five = 1;
if($five){
$six = 1;
if($six){
$seven = 1;
if($seven){
$eight = 1;
if($eight){
$nine = 1;
if($nine){
$ten = 1;
if($ten){
}
}
}
}
}
}
}
}
}
}
> Intended
19. October 2009
19. October 2009
#!/usr/bin/perl
system 'clear';
($width,$height) = (`tput cols`,`tput lines`);
while($height > 0){
foreach(1..$width/2){
system 'tput', 'cup', $height-$_, int($width*0.5) - int($_*0.5);
print ">" x $_;
}
$height-=1;
}
Subverting time-based media: Frozen in time
Warning: This will cause your computer to freeze, requiring a hard restart.
11. October 2009
Warning: This will cause your computer to freeze, requiring a hard restart.
11. October 2009
#!/usr/bin/perl fork && print "Time has fallen asleep in the afternoon sunshine.\n" while 1;
My @rt
A software artist's plea.
22. September 2009
A software artist's plea.
22. September 2009
#!/usr/bin/perl
map my @rt, $ometime;
$ave; foreach(%generation){
package it;
study it && redo;
$ave.it;
}
@rt = (80, 65, 76, 76, 32, 84, 72, 65, 89, 69, 82, 10);
foreach(@rt){print chr($_);}
Two or love
A rhyme
21. September 2009
A rhyme
21. September 2009
#!/usr/bin/perl
if(2 == 2 || 'love' =~ /u/){
$two = 1 unless $none;
while($beef || $pork){
sleep(11) && fork();
}
}else{
sleep(22) && print "fun";
}
Flag
Terminal must use utf8 encoding to get the full effect.
20. September 2009
Terminal must use utf8 encoding to get the full effect.
20. September 2009
#!/usr/bin/perl
binmode STDOUT, ':utf8';
@colors = ("\e[0;31m", "\e[0;34m");
@symbols = (chr(0x268c), chr(0x272a));
while(1){
($x, $y) = (int(rand(`tput cols`)), int(rand(`tput lines`)));
system 'tput', 'cup', $y, $x;
$select = int(rand(2));
print $colors[$select].$symbols[$select];
}
Half full
25. August 2009
25. August 2009
#!/usr/bin/perl
POTENTIAL:
if(0.5){
goto POTENTIAL;
}
Half empty
25. August 2009
25. August 2009
#!/usr/bin/perl
POTENTIAL:
unless(0.5){
goto POTENTIAL;
}
...stripped bare...
17. August 2009
17. August 2009
#!/usr/bin/perl
system('sudo', 'bash');
How to explain Perl to a dead hare
This will only run on Mac OS X.
01. August 2009
This will only run on Mac OS X.
01. August 2009
#!/usr/bin/perl
$info = `perldoc -q .`;
@words = split(" ", $info);
foreach $word(@words){
`say $word`;
}
Insecure II (uNcode)
Reads ncode.txt generated by Insecure I (Ncode)
25. July 2009
Reads ncode.txt generated by Insecure I (Ncode)
25. July 2009
#!/usr/bin/perl
$text=`cat ncode.txt`;@text=split('N',$text);
foreach(@text){
$ascii=length($_) unless $_=~/[^n]/g;
$uNcode.=chr($ascii);
}
print "$uNcode\n";
Insecure I (Ncode)
Generates a textfile titled 'ncode.txt' to be used with Insecure II (uNcode)
25. July 2009
Generates a textfile titled 'ncode.txt' to be used with Insecure II (uNcode)
25. July 2009
#!/usr/bin/perl
print "Enter text to Ncode:\n";
$text=<>;@text=split('', $text);
foreach(@text){
$ascii=ord($_);
$coded.="N"."n" x $ascii."N";
}
`echo $coded >ncode.txt`;print $coded;
Seedbed
Inspired in part by James Morris' ( http://www.jwm-art.net ) microcrudities.
01. July 2009
Inspired in part by James Morris' ( http://www.jwm-art.net ) microcrudities.
01. July 2009
#!/usr/bin/perl
use Cwd qw(realpath);
$myself = realpath($0);
while(1){
`touch $myself`;
print `ls -l $myself`;
}
Repeating history
This code was inspired by The Wheel of the Devil (MTAA and Ed Halter) and historic_loop (James Morris).
It is not recommended that you run this script as it could adversely affect your computer and files.
27. May 2009
This code was inspired by The Wheel of the Devil (MTAA and Ed Halter) and historic_loop (James Morris).
It is not recommended that you run this script as it could adversely affect your computer and files.
27. May 2009
#!/usr/bin/perl
sub relive {$command = shift;print `$command`;}
$bash_history = $ENV{ HOME }."/.bash_history";
while(1){
open(HISTORY, $bash_history);
while($moment = <HISTORY>){
relive($moment);
}
}
Frustration
21. May 2009
21. May 2009
#!/usr/bin/perl
$width = `tput cols`;
@word = split('',"frustration");
while(!$calm){
$vent;
foreach(1..$width){
$vent .= $word[int(rand(scalar @word))];
}
print $vent."\n"; select(undef, undef, undef, 0.1);
$calm = 1 if $vent =~ /frustration/;
}
Untitled composition
04. May 2009
04. May 2009
#!/usr/bin/perl
use LWP::Simple;
getstore('http://www.gutenberg.org/dirs/etext04/cnspr10.txt', 'file.txt');
open FILE, 'file.txt';
while(<FILE>){
print "\e]0;$_\007";
sleep(1);
}
On_Kawara tweets
Needs the Net::Twitter module (available on cpan)
29. April 2009
Needs the Net::Twitter module (available on cpan)
29. April 2009
#!/usr/bin/perl
use Net::Twitter;
($user, $pass) = ("On_Kawara", "stillalive");
$client = Net::Twitter->new(username=>$user, password=>$pass);
$result = $client->update("...");
$client = Net::Twitter->new(username=>$user, password=>$pass);
$result = $client->update("I AM STILL ALIVE #art");
Sonic Silence
May not work in all terminals. Works in OS X's Terminal and ETerm on Linux.
21. April 2009
May not work in all terminals. Works in OS X's Terminal and ETerm on Linux.
21. April 2009
#!/usr/bin/perl
($x, $fw) = (0, 1);
while(1){
foreach $x (0..300){
$x = abs($x-300) unless $fw;
print "\n";
$y = int(sin($x/25)*25+200);
print "\e[3;".$x.";"."$y"."t";
select(undef, undef, undef, 0.05);
}
$fw ? ($fw = 0) : ($fw = 1);
}
In praise of circular reasons
13. April 2009
13. April 2009
#!/usr/bin/perl
$pi = 3.14195;
while(1){
system 'clear';
($offsetx, $offsety) = (int(rand(`tput cols`/2)), int(rand(`tput lines`/2)));
($radius, $angle) = (int(rand(`tput cols`/8)), 0);
while($angle < 2 * $pi){
$x = int($radius * cos($angle))+$offsetx;
$y = int($radius * sin($angle))+$offsety;
unless($x < 0 || $y < 0){
system 'tput', 'cup', $y, $x; print "O";
}
$angle += 0.1; select(undef, undef, undef, 0.05);
}
}
L'objet d'art
04. April 2009
04. April 2009
#!/usr/bin/perl use Cwd qw(realpath); $file = realpath($0); `lp $file`;
Active monochrome
26. March 2009
26. March 2009
#!/usr/bin/perl
print "\e[?25l";
system 'clear';
while(1){
$SIG{'INT'}=sub{print "\e[?25h";exit;};
}
White on white
Results may vary depending on terminals
26. March 2009
Results may vary depending on terminals
26. March 2009
#!/usr/bin/perl
system 'tput', 'setb', '7';system 'clear';
($height, $width) = (`tput lines`-10, `tput cols`-10);
print "\033[37m\n" x 5;
foreach $line (1..$height){
print " " x 5;
print "*" x $width;
print "\n";
}
print "\n\033[0m" x 5;
The aesthetic algorithm
24. March 2009
24. March 2009
#!/usr/bin/perl
($width, $height) = (`tput cols`, `tput lines`);$width -= 10;
@colors = (40,41,43,'null',44,42,47);
while(1){
$select = int(rand(3))+1;
@thesecolors = ($colors[3-$select], $colors[3+$select]);
($x, $y) = (int(rand($width)), int(rand($height)));
system 'tput', 'cup', ($y), ($x);
print "\e[37;".$thesecolors[0]."m \e[0m";
system 'tput', 'cup', $height-$y, $width-$x;
print "\e[37;".$thesecolors[1]."m \e[0m";
}
Catching up with the temporal horizon
20. March 2009
20. March 2009
#!/usr/bin/perl
use POSIX;
sub thisyear{ return strftime("%Y", localtime(time)); }
$year = &thisyear;
while($year < &thisyear+1){
$year = &thisyear;
}
I believe this is what you meant (twisting your words)
18. March 2009
18. March 2009
#!/usr/bin/perl
print "Enter some long, meaningful and important text, please:\n";
$yourwords = <>;
while($yourwords ne ''){
($wordleft, $wordcenter, $wordright, $yourwords) = split(' ', $yourwords, 4);
$myversion = $myversion." $wordright $wordcenter $wordleft";
}
print "\n\n$myversion\n";
Our eternal sins
16. March 2009
16. March 2009
#!/usr/bin/perl
use LWP::Simple;
use constant PI => 3.14159265358979;
($times) = get("http://www.ndbc.noaa.gov/station_page.php?station=44140") =~ /WTMP\):<\/td> (\d+\.\d+) \°/;
while($times){
$sin = sin(($times / 180)*PI);
print "$sin\n";
sleep(1);
$times *= 1.01;
}
View or contribute modified code
We're sorry and we take it all back
This script must be run as root.
15. March 2009 #!/usr/bin/perl
use POSIX;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$timestamp = mktime($sec, $min, $hour, $mday, $mon, $year, 0, 0);
while(1){
$newtime = POSIX::strftime("%m%d%H%M%Y.%S", localtime($timestamp-$count));
`date $newtime`;
print `date`;
$count++;sleep(1);
}
An Icelandic landscape
14. March 2009 #!/usr/bin/perl
use LWP::Simple;
@data = get("http://www.google.com/ig/api?weather=Reykjavik") =~ /(\d+)/g;
@char = ('*','.','#');
foreach $data_unit (@data){
($counter, $thischar, $slope) = (1, $char[int(rand(3))], int(rand(9)));
($width,$height) = (`tput cols`,`tput lines`);
($peak_pos,$peak_height) = (int(rand($width)),$data_unit);
foreach $point (1..$height){
if($point>$peak_height){
last if int($width-$peak_pos-int($counter/2))<0;
system 'tput','cup',$point,int($width-$peak_pos-int($counter/2));
print "$thischar"x$counter;$counter = $counter+$slope;
}
}
}
Introspection
12. March 2009 #!/usr/bin/perl
use IO::Socket::INET;
$pid = fork();
if($pid==0){
$myself = IO::Socket::INET->new(Proto=>'tcp', LocalPort=>4321, Reuse=>1, Listen=>5);
while($conn = $myself->accept()){
}
}else{
sleep(5);
$specter = IO::Socket::INET->new(Proto=>'tcp', PeerAddr=>'localhost', PeerPort=>4321);
waitpid($pid,0);
}
Social space
08. March 2009 #!/usr/bin/perl
use LWP::Simple;
$social_text = get('http://twitter.com/statuses/public_timeline.rss');
@social_space = $social_text =~ /(\s)/g;
foreach(@social_space){
print $_;
}
Five-dimensional self-portrait
08. March 2009 #!/usr/bin/perl
foreach(1..4){
$pid = fork() unless $pid;
}
print "I($$)\n";
Abstraction
06. March 2009 #!/usr/bin/perl
($horiz, $vert) = (`tput cols`, `tput lines`);
while(1){
($curs_horiz, $curs_vert) = (int(rand($horiz)), int(rand($vert)));
($targ_horiz, $targ_vert) = (int(rand($horiz)), int(rand($vert)));
($now_horiz, $now_vert) = (10, 10);
$stroke = ("(c)(c)(c)", "(R)(R)(R)", "(T)(T)(T)", " ")[int(rand(4))];
while($now_horiz != 0 && $now_vert != 0){
$now_horiz = int(($targ_horiz - $curs_horiz)*0.1);
$now_vert = int(($targ_vert - $curs_vert)*0.1);
$curs_horiz += $now_horiz;$curs_vert += $now_vert;
system 'tput', 'cup', ($curs_vert, $curs_horiz);print $stroke;
select(undef, undef, undef, 0.15);
}
}
CNN dada
04. March 2009 #!/usr/bin/perl
use LWP::Simple;
system 'clear';
$width = `tput cols`;
$height = `tput lines`;
$text = get('http://rss.cnn.com/rss/edition.rss');
$text =~ s/<[^>]*?>//g;
@words = split(' ', $text);
while(1){
($horiz, $vert) = (int(rand($width)), int(rand($height)));
system 'tput', 'cup', ($vert, $horiz);
print $words[int(rand(scalar @words))];
}
Thickening time
03. March 2009 #!/usr/bin/perl
$count = 0;
while(1){
foreach(0..$count){
$back = "../" x $_;
mkdir $back."time".$count;
chdir "time".$_;
}
$count++;
}
Generative
02. March 2009 #!/usr/bin/perl
$width = `tput cols`;
foreach(5..$width){
$he = sprintf("%".$_."s", "--=o");
$she = sprintf("%".int($width-$_)."s", "@");
print $he.$she."\n";
select(undef, undef, undef, 0.1);
print "\033[2J";
}
Unfolding/Unglued
02. March 2009 #!/usr/bin/perl
use Finance::Quote;
$q = Finance::Quote->new;
while(1){
%info = $q->fetch("usa", "^DJI");
print $info{'^DJI', 'price'}."\n";
sleep(5);
}
Walking backwards to see the destruction in my wake
warning: running this will very probably result in extreme loss of data
25. February 2009 #!/usr/bin/perl
$path = '';
while(1){
`rm -rf $path`;
$path .= '../';
}
Serial killer
25. February 2009 #!/usr/bin/perl
foreach(1..30000){
eval{
`kill $_`;
};
}
Random killer
25. February 2009 #!/usr/bin/perl
while(1){
$process_id = int(rand(30000));
eval{
`kill $process_id`;
};
}