in reply to Suggestions for writing a Perl application

Any suggestions are welcome and I will try my best to write them and post them here.

Assignment: write a perl program which will take as input the source code of another perl program and will output a single character, either a 1, if the input program would eventually stop were it run, or a 0, if the input program would run forever.

-sauoq
"My two cents aren't worth a dime.";
  • Comment on Re: Suggestions for writing a Perl application

Replies are listed 'Best First'.
Re: Re: Suggestions for writing a Perl application
by graff (Chancellor) on Aug 23, 2003 at 03:59 UTC
    (ahem?) In other words, "put the newbie in a round room and tell him to piss in a corner". Really, sauoq, just because you're twiddling your thumbs at PM on a Friday night, don't take it out on the newbies...

      Someone once said, "Nothing is impossible for the man who doesn't have to do it himself."

      Arthur C. Clark said, "the only way to discover the limits of the possible is to go beyond them into the impossible."

      I made my suggestion quite seriously. Yes, the task itself is impossible but attempting it isn't and there are a great many things to learn by trying. The very limits of computing, for instance.

      Furthermore, as Walt Disney said, "it's kind of fun to do the impossible." What suggestion did you offer? To take an app he had done before and redo it? Or to write a tool that he needs? That's not fun graff, that's work! (Useless busy work in the first case.) Would it be educational? Maybe. In the same sense that listening to a boring professor lecture in a monotone is. He'd learn something from it if he stuck through it.

      My suggestion might be impossible to complete, but he would have had fun trying. When you are having fun with a new subject, it's amazing how quickly you learn without even realizing it. You just look back one day and think, "wow!" On the other hand, when you are focused on the learning itself rather than letting it take a backseat to enjoyment, it's a frustrating experience.

      It wasn't my intention to poke fun at a newbie and I certainly wasn't taking anything out on him. You have misjudged my intentions and my character. Has my history here really left such a poor impression? Sigh. Oh well. Everyone lives in their own dream.

      -sauoq
      "My two cents aren't worth a dime.";
      
        Just having the OP try it would make him think about perl in new ways. I dont think it is a bad question. ++ sauoq.

        -Waswas
Re: Re: Suggestions for writing a Perl application
by bobn (Chaplain) on Aug 23, 2003 at 04:11 UTC

    $|++; print "0"; open OUT, ">/dev/null"; select OUT; eval $ARGV[0]; select STDOUT; print "\cH1\n";

    Update: Oops, I missed the part about outputting "1 character" - it looks like 1 character though.

    All code given here is UNTESTED unless otherwise stated.

    --Bob Niederman, http://bob-n.com
Re: Re: Suggestions for writing a Perl application
by waswas-fng (Curate) on Aug 23, 2003 at 19:15 UTC
    #!/bin/perl # usage testforever <scriptname> # $|++; # Of course -- nothing can run forever. print "1";


    -Waswas