Created
March 23, 2018 16:13
-
-
Save sekia/17916abee28f5b051d30934a69834c45 to your computer and use it in GitHub Desktop.
Punnig operator for scalars.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature qw/say/; | |
use PadWalker qw/var_name/; | |
my $foo = 42; | |
my $bar = 'blah blah blah'; | |
my $baz = undef; | |
use Data::Dumper; | |
say Dumper +{ pun $foo, $bar, $baz }; | |
sub pun { | |
map { (var_name(1, \$_) =~ s/^\$//r) => $_ } @_; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment