Skip to content

Instantly share code, notes, and snippets.

@nicomen
Created July 12, 2016 15:55
Show Gist options
  • Save nicomen/4692394cfb876c9b878f362dfc0740cf to your computer and use it in GitHub Desktop.
Save nicomen/4692394cfb876c9b878f362dfc0740cf to your computer and use it in GitHub Desktop.
$ perl -wle 'sub foo (&$*) { print "@_"; } foo(sub {*STDOUT},"a", "b");'
CODE(0x2561da8) a b
$ perl -wle 'sub foo (&$*) { print "@_"; } foo {*STDOUT} "a", "b";'
CODE(0x184ed68) a b
# How do I from inside foo distinguish the calls, to treat the first param magically?
# print example:
$ perl -wle 'print sub{*STDOUT},"a", "b";'
CODE(0x1a78d70)ab
$ perl -wle 'print {*STDOUT} "a", "b";'
ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment