marto:

OVERLY COMPLEX! I think you could have simplified it to[1]:

#!/usr/bin/perl use strict; use warnings; print "Enter a number:"; my $input = <STDIN>; print "47\n";

In fact, when I read your response, I was transported back in time to high school. My friends and I formed a small informal computer club where we each created programs for the amusement of others. My friend Tony created "Super Star Trek 4.71" which amused the hell out of me. I no longer have the source code to it, as little output from the TTY[2] still lingers at the house. But a close approximation in perl[3] would be like:

#!/usr/bin/perl use strict; use warnings; use Time::HiRes 'usleep'; $|=1; my $A; sub PR1NT { my $msg = shift; my @chars = split //,$msg; while (defined(my $t = shift @chars)) { usleep 100000; print $t; } } sub INPUT { print "? "; my $a = <>; return $a; } L0010: PR1NT "WELCOME TO SUPER STAR TREK VERSION 4.71\n"; L0015: PR1NT "\n"; L0020: PR1NT "A SPACE ADVENTURE SURE TO THRILL THE SOUL!\n"; L0030: PR1NT "COPYRIGHT 1979 BY ANTHONY D. ENNIS\n"; L0040: PR1NT "\n"; L0050: PR1NT "WOULD YOU LIKE INSTRUCTIONS"; L0060: $A = INPUT(); L0070: PR1NT "\n"; L0080: PR1NT "WHAT IS YOUR FAVORITE NUMBER"; L0090: $A = INPUT(); L0100: PR1NT "YOU WIN!!!!\n"; L0110: PR1NT "\n"; L0120: PR1NT "WOULD YOU LIKE TO PLAY AGAIN"; L0130: $A = INPUT(); L0140: PR1NT "\n"; L0150: goto L0010;

Notes:

[1] I could've left out the use warnings/errors boilerplate, but we wouldn't want to give people bad habits, would we?

[2] Last year at about this time, I dug up a printout of his D&D program from the same era and gave it to him. Now he has an Android version on his phone. He needs to give me a copy of it! I hate to think of how many rolls of paper our computer club wasted on that game. ;^)

[3] Yep, I actually wasted 15 minutes of my life recreating Tony's joke game.

The rendition of his game here is from memory, so it's obviously not exactly the same. But I'm sure it's not far from the mark!

Update: I forgot the "just kidding" note. This was just a joke response because marto triggered an ancient memory.

Update: Had some "junk" in the star trek program, now removed. (Looks like I pasted a copy of the first code snippet into the second one.) Thanks to N-Wing for catching it! Also made a couple tweaks to make it a little closer to the original.

Late update: (Late==2018-06-07) I forgot to mention that the original program was in BASIC. (Our high school club was based on a time-share account on an HP-2000 with their version of BASIC. Obviously, I perlified it a bit...)

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to OT: TOO COMPLEX! (Was Re^2: how to print only 47 and another number...) by roboticus
in thread how to print only 47 and another number will rejected and when user give 47 that number only print ? by virudinesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.