Thanks at first, dear Ikegami.

I see that I have to describe a little bit more, what I'm trying to do. But bag you pardon, please don't laugh too much about me, it's my fault.

I have written now a short file of code, which should describe nearly, what I want to do.

___ testpar.pl ___

#!/usr/bin/perl use objectA; my %myhash = ( 'a.x' => 1, 'b.y' => 2, 'c.x' => 3, ); my $objA = objectA->new(); $objA->map_query( \%myhash ); print $_->name, ': ', $_->val, "\n" for $objA->parameter( 'a.x' ); print $_->name, ': ', $_->val, "\n" for $objA->parameter( 'b.y' ); return;

___ objectA.pm ___

package objectA; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub map_query { my $self = shift; my $hash = shift; map { $self->{ values }->{ $_ } = $$hash{ $_ }; } keys %{ $hash }; } sub parameter { my $self = shift; my $para = shift; my $param = $para =~ m/^([^\.]*\.)(.*?)$/i ? $2 : $para; # return { sub name{ $param; }, sub value{ $self->{ values }->{ $pa +ra } || ''; } }; my $name = \&parameter_name( $param ); my $val = \&parameter_value( $self->{ values }->{ $para } ); return { $name, $val }; } sub parameter_name { my $param = shift; return $param; } sub parameter_value { my $parval = shift; return $parval || ''; } 1;

In reply to Re^2: how to let sub return hash of 2 sub? by toohoo
in thread how to let sub return hash of 2 sub? by toohoo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.