Advertisement
Guest User

Untitled

a guest
Feb 24th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. I have an route endpoint like:
  2. my $self = shift();
  3.  
  4. my $t = {
  5. id => $self->param('id'),
  6. attr => $self->param('attr'),
  7. title => $self->param('title'),
  8. body => $self->param('body'),
  9. };
  10.  
  11.  
  12. I expect it to end up like
  13. $t = {
  14. id => 123,
  15. attr => undef,
  16. title => 'Testing 1 2 3',
  17. body => 'Four score and...'
  18. };
  19.  
  20. It actually ends up creating
  21. $t = {
  22. id => 123,
  23. attr => 'title',
  24. 'Testing 1 2 3' => 'body',
  25. 'Four score and...' => undef
  26. };
  27.  
  28. with an "odd number of elements" warning
  29.  
  30. Do I really have to do
  31. my $t = {
  32. id => $self->param('id') || undef,
  33. attr => $self->param('attr') || undef,
  34. title => $self->param('title') || undef,
  35. body => $self->param('body') || undef
  36. };
  37.  
  38. just in case to prevent this behavior? This seems REALLY dangerous in conjunction with DBIx::Class and such.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement