in reply to Target method with Selenium::Screenshot
Hello Chaoui05
Your recent posts have queried storage in Arrays, and shown attempts to store Arrays in Hashes, and vice versa.
An array is indexed in an Ordered manner, typically from $array_element[0] to $array_element[-1]. Where the negative sign indicates to enumerate reversely from the end of the array.
An hash is a variant of an array. It is an Associated Array, where the elements are treated as key/value pairs. The indices are not integers, they are static strings, and called keys. This confers the attribute of being Un-ordered and can be useful for clarity, where the element is named recognisably, rather than indexed by number. $hash_element{ $key =~ /\A[_0-9a-zA-Z]+\z/ } = $value
Importantly to note, arrays (inc. hashes) can only hold scalar elements. To situate an array as an element of an array, the array is assigned to a scalar variable in the form of a reference.
Practically, by usage you come to learn the difference, the usual problems occurring when trying to access or assign to an array/hash ref. Where the access or assignment is of the wrong type. As attested to by the error message - (Not a HASH reference at ... )
Try these explanations, to help get a clearer understanding of the context of the data. I say context, as you can also apply the array sigil to the front of the array access to access a list of elements within an array rather than only one element. @array_elements[ 0 .. 3 ]
Further, Objects are a reference to any data type, that can be referenced. But are also associated to a namespace or package through Bless, essentially a named reference. As a fairly simple overview. This means that they can also be stored in arrays, as references, by intention, are scalars.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Target method with Selenium::Screenshot
by Chaoui05 (Scribe) on May 31, 2016 at 12:41 UTC | |
by Don Coyote (Hermit) on Jun 07, 2016 at 07:12 UTC |