Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Using user input to return variable typed.

by 2teez (Priest)
on Nov 12, 2012 at 21:23 UTC ( #1003508=note: print w/replies, xml ) Need Help??


in reply to Using user input to return variable typed.

Hi, myelinviolin,
Please, format your question properly.
Check this How do I post a question effectively?

I'm not sure how to call out variable names from the user input to display values that have already been calculated previously in the program

You can try this,or modify for your usage:

use warnings; use strict; my %variable_table = ( INT => 5, STR => 'HOME',); while (1) { print "What would you want to know: "; chomp( my $type = <STDIN> ); last if $type eq 'exit'; if ( exists $variable_table{$type} ) { print $type, ' : ', $variable_table{$type}, $/; } else { next; } }

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003508]
help
Chatterbox?
[stevieb]: ohhh, aaaand, I just learned that you can power an Arduino (Uno at least) by connecting any single analog pin to 5v on the Pi GPIO! That's bloody handy

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-06-22 23:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.