Skip to content

Instantly share code, notes, and snippets.

@sekia
Created March 23, 2018 16:13
Show Gist options
  • Save sekia/17916abee28f5b051d30934a69834c45 to your computer and use it in GitHub Desktop.
Save sekia/17916abee28f5b051d30934a69834c45 to your computer and use it in GitHub Desktop.
Punnig operator for scalars.
#!/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