
BillKSmith
Veteran
Jul 29, 2010, 4:51 AM
Post #2 of 4
(1620 views)
|
|
Re: [vishwa787] how to access the value of a variable like $value = 10
[In reply to]
|
Can't Post
|
|
You need a hash.
sub get_value { my %values = ( value => 10, weight => 3, price => 290, ); (my $string) = @_; return $values{$string}; } You don't really need the subroutine. You can put the hash in the main program. Access it just like the return. Good Luck, Bill
|