for my $y ( 0 .. $image->getheight() - 1 ) { for my $sample ($image->getsamples(y => $y)) { # do something with the sample } }