in reply to WWW::ImagesHack
Use of the module then becomes:our KEY_LIST => [ qw/ thumbnailForWebsite thumbnailForForums1 thumbnailForForums2 hotlinkForForums1 hotlinkForForums2 hotlinkForWebsite showImage directLinkToImage / ]; sub get { my $self = shift; my $key = shift; # could grep @{&KEY_LIST} here too to check for valid key return exists $self->{liste}->{$key} ? $self->{liste}->{$key} : unde +f; } # this could be left the same or changed to this: sub get_all { my $self = shift; return { map { $_ => $self->{liste}->{$_} } @{&KEY_LIST} }; } # note: could also replace get_all() with get() or get('all') # and note that the loop in upload() becomes just: foreach( @{&KEY_LIST} ){ ... }
print $ih->get('thumbnailForWebsite'), "\n"; print $ih->get('thumbnailForForums1'), "\n"; print $ih->get('thumbnailForForums2'), "\n"; print $ih->get('hotlinkForForums1'), "\n"; print $ih->get('hotlinkForForums2'), "\n"; print $ih->get('hotlinkForWebsite'), "\n"; print $ih->get('showImage'), "\n"; print $ih->get('directLinkToImage'), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: WWW::ImagesHack
by Pied (Monk) on Sep 15, 2005 at 15:51 UTC | |
by davidrw (Prior) on Sep 15, 2005 at 20:10 UTC |