Skip to content

Instantly share code, notes, and snippets.

@nicomen
Created July 12, 2016 15:59
Show Gist options
  • Save nicomen/79cbf2a7d26775e8e1daef1937e6fd9a to your computer and use it in GitHub Desktop.
Save nicomen/79cbf2a7d26775e8e1daef1937e6fd9a to your computer and use it in GitHub Desktop.
Block syntax question
$ 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 can I from inside the sub distinguish the calls?
# 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