fork(3) download
  1. #! /usr/bin/perl
  2. # Nathaniel James Shaw
  3.  
  4. use Tk;
  5.  
  6. $X = 750;
  7. $Y = 100;
  8.  
  9. $root = new MainWindow(-title=>'Perl/Tk example');
  10. $c = $root->Canvas(-width=>800,-height=>800,-background=>'black')->pack();
  11. $root->bind("<q>", \&done);
  12.  
  13.  
  14. sub loop
  15. {
  16.  
  17. $D = rand();
  18.  
  19. print ("The current random number is $D.");
  20.  
  21. if ($D < 0.3) {$CurrPtx = $X; $CurrPty = $Y*0.16};
  22. if (($D > 0.3)&&($D < 0.14)) {$CurrPtx = 0.2*$X - 0.26*$Y; $CurrPty = 0.23*$X + 0.2*$Y +0.44};
  23. if (($D > 0.14)&&($D < 0.27)) {$CurrPtx = -(0.15*$X) + 0.28*$Y; $CurrPty = 0.26*$X + 0.24*$Y + 1.6};
  24. if (($D > 0.27)&&($D < 1.00)) {$CurrPtx = 0.85*$X + 0.04*$Y; $CurrPty = -(0.04*$X) + 0.85*$Y + 1.6};
  25.  
  26.  
  27. $CurrPtx = $CurrPtx*5;
  28. $CurrPty = $CurrPty*5;
  29.  
  30. $c->createLine($CurrPtx,$CurrPty,$CurrPtx+1,$CurrPty+1,-fill=>'green');
  31.  
  32. print ("The current coords are these: $CurrPtx, $CurrPty.\n");
  33.  
  34. $X = $CurrPtx;
  35. $Y = $CurrPty;
  36.  
  37. }
  38.  
  39. print "Triangle Created.\n";
  40. print "Press q at any time to quit.\n";
  41.  
  42. sub done {'Here Is Your Triangle.\n'; exit();};
  43.  
  44.  
  45. $root->repeat(1, \&loop);
  46.  
  47. MainLoop;
  48.  
Runtime error #stdin #stdout #stderr 0s 18256KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Can't locate Tk.pm in @INC (you may need to install the Tk module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at prog.pl line 4.
BEGIN failed--compilation aborted at prog.pl line 4.