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.


Bless my $CODEREF, Classy

In reply to Re: Target method with Selenium::Screenshot by Don Coyote
in thread Target method with Selenium::Screenshot by Chaoui05

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.