git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [git/perl] unusual syntax?

From
David Christensen <david@endpoint.com>
Date
Aug 4, 2008, 15:01 UTC
Message-ID
<77D646CF-448B-434A-B969-653931B4A756@endpoint.com>
In-Reply-To
<be6fef0d0808032149p651309a8o773dca5f16923ee1@mail.gmail.com>
Show 13 quoted lines
> sub _close_hash_and_insert_object {
> 	my ($self) = @_;
>
> 	return unless defined($self->{hash_object_pid});
>
> 	my @vars = map { 'hash_object_' . $_ } qw(pid in out ctx);
>
> 	command_close_bidi_pipe($self->{@vars});
> 	delete $self->{@vars};
> }
> $self->{@vars} evaluates to undef. i can't find any mention of using
> arrays to dereference objects in the manual and elsewhere; is this a
> mistake?

This is a hash slice notation, returning an array of hash values matching the corresponding keys. 5.10 removed some syntax warts in the case of hash slices; this is more portably expressed as @{$self} {@vars}; this should work in 5.10 and earlier versions, and so is the preferred syntax.

Regards,

David -- David Christensen End Point Corporation david@endpoint.com

Previous: Junio C Hamano
Message 9 of 9 in “[git/perl] unusual syntax?”
  1. Ray ChuanAug 4, 2008
  2. Fix hash slice syntax errorAbhijit Menon-Sen, Aug 4, 2008
  3. Git.pm: Fix internal git_command_bidi_pipe() usersPetr Baudis, Aug 4, 2008
  4. Junio C HamanoAug 4, 2008
  5. Petr BaudisAug 4, 2008
  6. Junio C HamanoAug 4, 2008
  7. Git.pm: localise $? in command_close_bidi_pipe()Abhijit Menon-Sen, Aug 4, 2008
  8. Junio C HamanoAug 5, 2008
  9. David ChristensenAug 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.