in reply to Accessing values of a Hash object
The following reworked sample code may give you some hints:
use strict; use warnings; package ngetlogstdin; sub new { my $self={}; $self->{o}="ngeterr.log"; $self->{a}=undef; $self->{i}={110 => 'FB', 100 => 'F'}; $self->{F}=undef; $self->{B}='http://wibble.wobble.com'; bless $self; return $self; } sub access { my $self=shift; my $arg=shift; print $arg; # Note that "result" of print is the return value } 1; package main; my $obj=new ngetlogstdin; for my $key(keys %$obj){print "$key\n"}; my $arg='tomatoes'; my $value=$obj->access($arg); print $value;
Prints:
F a B i o tomatoes1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing values of a Hash object
by dReKurCe (Scribe) on Mar 13, 2007 at 21:21 UTC | |
by GrandFather (Saint) on Mar 13, 2007 at 21:38 UTC |