Translating a Perl reference to OO PHP?

So I tripped across another oddity in translating the old developers Perl script into Object Orientated PHP, this little Perl reference statement has had me scratching my head for quite a while, but I haven't been able to figure it out via Google or friends.

I've tried my best to write out what I believe it to mean, but am uncertain if it is right. Could someone tell me if I figured it out or if I'm off? Thanks ahead of time.

The perl snippet is:

!$state->{$msg->{hash}}

I believe it means one of the two of these in OO PHP?

!$this->state[$this->msg['hash']] //or?
$this->state != $this->msg['hash']

Am I even in the ballpark?

UPDATE I was told this is a has reference, not an array reference, but I'm uncertain since $msg->{grey}, $msg->{hash}, $msg->{domain} etc all exist in the same sub?

Answers


Actually, on a second glance, $state is a hash reference of some kind (although it could also be a blessed object of some class), and $state->{$msg->{hash}} is the value of %$state corresponding to the key $msg->{hash} (which, in turn, is the value of %$msg that corresponds to the key "hash").

So, assuming that $state and $msg are only hash references (and not specific objects), they actually correspond to arrays in PHP (one of the really dumb things about PHP is that there is no difference between an array and an associative array).

So, it would be !$state[$msg['hash']] in PHP.


Need Your Help

load function parameters in inlined ptx

visual-studio-2008 cuda ptx

I have the following function with inline assembly that works fine on debug mode in 32 bit Visual Studio 2008:

developing windows phone 8 app with javascript using visual studio 2013 ultimate update 2

javascript html5 windows-phone-8 visual-studio-2013 windows-phone-8.1

I want to develop windows phone 8 app with java-script using visual studio ultimate 2013 update 2 but i couldn't find there option for windows phone 8, there is only option for 8.1, please help me

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.