Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- use utf8;
- use diagnostics;
- use Data::Dumper;
- sub takeshash (\%) {
- my ($ref) = @_;
- takesscalar($ref);
- #takesscalar $ref; # cannot call on unblessed reference
- takeshashref($ref);
- #takeshashref(%{$ref}); # incorrect output
- #takeshashref %{$ref}; # bareword not allowed
- }
- sub takeshashref (\%) {
- my ($ref) = @_;
- print "takeshashref\n";
- print Dumper([$ref]);
- }
- sub takesscalar ($) {
- my ($ref) = @_;
- print "takescalar\n";
- print Dumper([$ref]);
- }
- my %hash = (
- foo => 'bar',
- baz => 'zorp',
- );
- takeshash(%hash);
Add Comment
Please, Sign In to add comment