#!/usr/bin/perl
use strict;
use warnings;
print "\nThis program is for people who don't know how to program",
"\nin Perl. This program will write a program FOR YOU.",
"\nYou don't have to do anything! Just run the program until",
"\nyou get the desired result. How do you like that idea!?";
my $PROGRAM = "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\n";
my $PERL_PIECES = " (){;}\n0123456789\"abcdefghijklmnopqrstuvwxyzABCDE
+FGHIJKLMNOPQRSTUVWXYZ_-+[]<>|\\/:`'?!.,=~\@\$\%^&*#";
for (my $i = 0; $i < 30; $i++)
{
my $PTR = (rand() * 120) % length($PERL_PIECES);
$PROGRAM .= substr($PERL_PIECES, $PTR, 1);
}
print "\n\n\nWe've come up with a great perl script just for you:\n",
'-' x 75, "\n", $PROGRAM, "\n", '-' x 75;
print "\n\n\nOkay. You ready? (y/n) ";
$a = <STDIN>;
substr($a, 0, 1) eq 'y' or exit;
open my $FILE, '>test1234.pl' or die 'Dude, I cant even create file!';
binmode $FILE;
print $FILE $PROGRAM;
close $FILE;
chmod 0755, 'test1234.pl';
system('perl test1234.pl');
$a = <STDIN>;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|