Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Perl Monk, Perl Meditation
 
PerlMonks  

This turned out not to be the disaster I expected

by Dominus (Parson)
on Jun 06, 2007 at 19:28 UTC ( #619650=perlmeditation: print w/ replies, xml ) Need Help??

I was initially thinking about a module that would generate and execute every possible piece of Perl code when it was loaded. Such a module would be very useful, because once you loaded it, you wouldn't have to actually run your program; it would already have done whatever it was that you wanted.

As a first cut, I wrote:

$s = "a"; while (length($s) < 100) { eval $s; $s++ }
realizing that this wasn't going to be what I wanted, because it doesn't generate any code with spaces or punctuation, but I thought it might be fun, at least as a joke. It looks like it is going to take a long time to execute, so I ran it with some fear that it might crash my machine or do something else bad.

But actually it executes rather quickly, and nothing bad happens. As I said, it was not the disaster I expected.

Can you predict the results?

Comment on This turned out not to be the disaster I expected
Download Code
Re: This turned out not to be the disaster I expected
by BrowserUk (Pope) on Jun 06, 2007 at 19:37 UTC
Re: This turned out not to be the disaster I expected
by imp (Priest) on Jun 06, 2007 at 19:39 UTC
Re: This turned out not to be the disaster I expected
by kyle (Abbot) on Jun 06, 2007 at 19:41 UTC
Re: This turned out not to be the disaster I expected
by shmem (Canon) on Jun 06, 2007 at 21:36 UTC

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: This turned out not to be the disaster I expected
by naikonta (Curate) on Jun 07, 2007 at 02:53 UTC
    This can be a way to find a c00l n4m3 or some magic number?
    perl -le '$s = shift; while (length($s) < 100) { print $s; eval $s; $s +++; }'
    But this one is less fun :-)
    perl -le '$s = shift; while (length($s) < 100) { print $s; eval $s; $s +++; }' 'kill 9, $$'

    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Re: This turned out not to be the disaster I expected
by djp (Hermit) on Jun 07, 2007 at 03:03 UTC
    I'm predicting you hit '?' early in the piece. Update: didn't hide my answer as others did.

      No, because magical autoincrement on alphanumeric strings never strays outside the alphanumeric character set.

Re: This turned out not to be the disaster I expected
by gaal (Parson) on Jun 07, 2007 at 16:29 UTC
    I seem to vaguely recall someone discovering this sometime in the 90ies, maybe even on c.l.p.m.
Re: This turned out not to be the disaster I expected
by diotalevi (Canon) on Jun 09, 2007 at 00:29 UTC

    It leaks memory while it's working.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: This turned out not to be the disaster I expected
by ambrus (Abbot) on Jun 10, 2007 at 00:23 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://619650]
Approved by imp
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-04-17 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (445 votes), past polls