Once again here is the new version of my new() method.
sub new {
my ($self, $tn, $key, $value);
my $class = shift;
if ($_[2] =~ /^\d+$/) { # this suppose no %hash key is all numeric
$tn = Telephone::Number->new(shift, shift, shift);
} else {
$tn = Telephone::Number->new(shift);
}
my ($smstext, %hash) = @_;
$self = bless {
'tn' => $tn,
'smstext' => $smstext,
'cookie_jar' => exists $hash{cookie_jar} ?
delete $hash{cookie_jar} :
"lwpcookies.txt",
}, $class;
@{$self}{keys %{$tn}} = @{$tn}{keys %{$tn}};
@{$self}{keys %hash} = @hash{keys %hash}; #dragonchild suggest
+ion
$self;
}
Now i have created a new Telephone::Number object (temporary namespace) cause i need it to do some dirty work parsing phone numbers... but this is not the point.
With the line
@{$self}{keys %{$tn}} = @{$tn}{keys %{$tn}}; i got a copy of the values of
$self->{tn} in
$self, but that's not what i want.
I'd like to have in
%{$self} aliases to the hash variables in
%{$self->{tn}} so that when i change
$self->{some_key_from_tn} i change also
$self->{tn}->{some_key_from_tn}
I hope i explained what i need, maybe just a bit confused.
Thanks for advice.
Giulio
Edit kudra,
2001-10-30
Changed title
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.