Perl- print hash values while the key is matched -
i trying print hash values using html tags inside perl code. instead of values 1
. happens when try print hash values inside sub
. right way ?
package shembull; %rhash= ( lbl_name => "l", lbl_surname => "g", txt_nameemri => "n", txt_surname => "m", btn_submit => "submit", ); sub lbl_input { $value = @_; return "<label>".$value."</label>"; } sub txt_input { $value = @_; return "<textarea>".$value."</textarea>"; } sub btn_input { $value = @_; return"<button>".$value."</button>"; } foreach $tmp (keys %rhash){ if($tmp =~/lbl/){ print lbl_input ($rhash{$tmp}); } elsif($tmp =~/txt/){ print txt_input ($rhash{$tmp}); } elsif($tmp =~/btn/){ print btn_input ($rhash{$tmp}); } }
what may e reason? thank !
my $value = @_;
this put number of elements of @_
in $value
- evaluating list in scalar context returns number of elements.
you can use instead:
my ($value) = @_;
Comments
Post a Comment