Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Stumped UPDATED!?!?!

by Thelonius (Priest)
on Feb 11, 2008 at 05:45 UTC ( #667326=note: print w/ replies, xml ) Need Help??


in reply to Re: Stumped UPDATED!?!?!
in thread Stumped UPDATED!?!?!

For example,

use strict; use warnings; $| = 1; # auto flush stdout sub more { print "more()\n" } sub fallover { print "fallover()\n" } sub leave { print "Bye!\n"; exit; } my %cmdhash = ( fun => \&more, laugh => \&fallover, exit => \&leave, ); print "Welcome to johns fun house\n"; while (1) { print " : "; my $command=<>; chomp $command; if (my $func = $cmdhash{$command}) { $func->(); } else { print "I'm afraid I don't know how to \"$command\"\n"; } }


Comment on Re^2: Stumped UPDATED!?!?!
Download Code
Replies are listed 'Best First'.
Re^3: Stumped UPDATED!?!?!
by chromatic (Archbishop) on Feb 11, 2008 at 06:44 UTC
    $| = 1; # auto flush stdout

    Why?

        I completely missed that. You're right.

      When I ran this without that, I didn't see the prompt or any of the output. I was running ActivePerl 5.8.8 in an rxvt window. If I run cygwin perl, I don't need the $|=1, or if I run either perl in a DOS box, I don't need it. Dunno why.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://667326]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2015-07-30 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls