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.
|