Assign method call to hash value?

Mike Stok mike at stok.ca
Tue Jan 29 02:33:32 GMT 2013


Have you tried reading

  perldoc -f scalar

Hope this helps,

Mike

On 2013-01-28, at 8:45 PM, gvim <gvimrc at gmail.com> wrote:

> 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

-- 

Mike Stok <mike at stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.







More information about the london.pm mailing list