in reply to Re: Perl 5.10 eval($string) memory leak
in thread Perl 5.10 eval($string) memory leak
Here is the simplest example of what I'm playing with.
#!/usr/bin/perl use strict; my $DOWARN = 0; BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } } my $symbol_list = "symbolsV1p1.dat"; my @symbol_pool = (); my $symbol_size = 0; my $index = 0; my $seed = "while "; my $embryo = $seed; my $MAX_ITER = 10; my $i = 0; my $result = undef; print "test.pl started...\n"; # Open my file list of symbols and functions # I will randomly jumble around and eval. open(SYMBOLS, "<$symbol_list") or die "Could not open $symbol_list: $! +\n"; while (<SYMBOLS>) { chomp $_; print "symbol_pool character is: $_\n"; push(@symbol_pool, $_); } close(SYMBOLS); $index = int(rand($symbol_size)); print "Initial embryo is:\n$embryo\n"; while (1) { $embryo = $embryo . $symbol_pool[$index] . ";"; $result = eval($embryo); # Print out the successful string eval's if ($result != undef) { print "\n\nA working one liner has been generated!\n"; print "$embryo\n"; print "Line: $i\n\n"; $i++; } # Truncate the string to keep it from growing infinitely long if (length($embryo) >= 80) { $embryo = $seed; } # Stop the script after I get a few successful string eval's if ($i == $MAX_ITER) { print "Program finished\n"; exit(0); } $index = int(rand($symbol_size)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl 5.10 eval($string) memory leak
by BrowserUk (Patriarch) on Aug 15, 2013 at 20:26 UTC | |
by fuzzmonkey (Sexton) on Aug 16, 2013 at 00:24 UTC | |
|
Re^3: Perl 5.10 eval($string) memory leak
by tobyink (Canon) on Aug 16, 2013 at 14:12 UTC | |
by fuzzmonkey (Sexton) on Aug 16, 2013 at 20:29 UTC |