$screenshots as depicted in $screenshots{$browser} is not an array, it's a hash. So you want to create a hash that contains all of the objects; is that correct?
Here's a very basic example of how you could do this, using a dummy package for testing (I know nothing of Selenium::Screenshot).
use warnings; use strict; use Data::Dumper; package Blah; sub new { my ($class, $browser) = @_; return bless {browser => $browser}, $class; } package main; # the example you're interested in is below my %screenshots; for my $browser ('ie', 'ff', 'chrome'){ $screenshots{$browser} = Blah->new($browser); } print Dumper \%screenshots;
Output:
$VAR1 = { 'ie' => bless( { 'browser' => 'ie' }, 'Blah' ), 'ff' => bless( { 'browser' => 'ff' }, 'Blah' ), 'chrome' => bless( { 'browser' => 'chrome' }, 'Blah' ) };
In reply to Re: Pass an object, a variable in an Array
by stevieb
in thread Pass an object, a variable in an Array
by Chaoui05
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |