Guest User

Untitled

a guest
Apr 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use utf8;
  6.  
  7. use diagnostics;
  8. use Data::Dumper;
  9.  
  10. sub takeshash (\%) {
  11. my ($ref) = @_;
  12. takesscalar($ref);
  13. #takesscalar $ref; # cannot call on unblessed reference
  14. takeshashref($ref);
  15. #takeshashref(%{$ref}); # incorrect output
  16. #takeshashref %{$ref}; # bareword not allowed
  17. }
  18.  
  19. sub takeshashref (\%) {
  20. my ($ref) = @_;
  21. print "takeshashref\n";
  22. print Dumper([$ref]);
  23. }
  24.  
  25. sub takesscalar ($) {
  26. my ($ref) = @_;
  27. print "takescalar\n";
  28. print Dumper([$ref]);
  29. }
  30.  
  31. my %hash = (
  32. foo => 'bar',
  33. baz => 'zorp',
  34. );
  35.  
  36. takeshash(%hash);
Add Comment
Please, Sign In to add comment