Assign method call to hash value?

gvim gvimrc at gmail.com
Tue Jan 29 01:45:17 GMT 2013


I have a form validation sub thus:

sub val {
   my $params = shift;
   my $r = Data::FormValidator->check($params, \%register);
   my $passed = $r->success && !$r->has_unknown;
   my $valid = $r->valid;
   my $missing = $r->missing;
   my $invalid = $r->invalid;
   my $unknown = $r->unknown;
   return { passed => $passed, valid => $valid, missing => $missing, 
invalid => $invalid, unknown => $unknown };
}

It works but is it possible to call $r->method directly when assigning a 
hash value, which is still a scalar context? I tried this:

   return { passed => $passed, valid => $r->valid, missing => 
$r->missing, invalid => $r->invalid, unknown => $r->unknown };

... but didn't get the same result. Adding $r->method() didn't make any 
difference, nor did curly-quoting: {$r->method()}.

gvim


More information about the london.pm mailing list