The $my_module becomes the $self argument in the parse routine, and that's what you're assigning to $resource. You need to do ...

sub parse { my ( $self, $resource, $something ) = @_; ... }

update: You can't do scalar on an array reference, you have to access the underlying array, THEN you can use a scalar context. You don't need to explicitly specify scalar context here, though it might be clearer for team mates who are less accustomed to getting the array size by using the array as a scalar. My preference, and common modern usage, is to use a number range rather than a C-style for loop, though it isn't wrong to do so ... you'll just have people mentioning 'modern usage' to you. You CAN simply use @$resource, but I have perltidy configured to remind me to use curly braces when using multiple sigils, because it clarifies more complicated cases. I wouldn't mind tolerating @$resource, but consistency MAY assist team members who are less comfortable with it, so I stick in the curlies.

for my $i ( 0..@{$resource} - 1 ) { ... }

As Occam said: Entia non sunt multiplicanda praeter necessitatem.


In reply to Re: array expected hash given by TomDLux
in thread array expected hash given by kosta

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.