Perl recognise string as scalar variable -
i have integer scalar variables named $a_cine
, $b_cine
, , on.
i have subroutine display
takes single argument 'a'
, 'b'
, 'c'
, etc.
i assign $letter = $_[0]
within subroutine. want pick value of $a_cine
or $b_cine
, assign new scalar variable $cine
.
i have tried $cine = '$'.$view."_cine"
, recognizes $cine
string $a_cine
(which should). however, there way interpret $a_cine
can numeric value of scalar $a_cine
has been defined?
using symbolic references bad idea. instead should utilize hash. set up, %cine
, utilize $cine{a}
in place of $a_cine
etc. can write
sub subroutine { ($view) = @_; $cine = $cine{$view}; ... }
perl
No comments:
Post a Comment