📜 ⬆️ ⬇️

How to call a method that does not exist

Some modules have a habit of creating objects from dynamic classes, for example, OO-interfaces to databases like to make classes from the names of table fields. In addition, often want to refer to the structure element, which may not exist. Pearl transfers appeal to elements that are not there, but elements of such elements are no longer. Like this is solved? This is what ordinary powder did:

; defined $ obj -> subobj ? $ obj -> subobj -> method: undef

When such structures have accumulated pretty much, I had to force myself to stop blunting:
')
; $ obj -> subobj and $ obj -> subobj -> method

Source: https://habr.com/ru/post/12135/


All Articles