Vadim Kutchin schreef:
> I have some function, such as:
Missing:
use strict;
use warnings;
> ===========================================
> sub func1 {
> my (%rez);
>
> $rez{one} = 'one';
> $rez{two} = 'two';
> $rez{seven} = 'seven';
>
> return %rez;
> }
sub func1 {
my %rez =
( one => 'first'
, two => 'second'
, seven => 'seventh'
);
return \%rez;
}
> ===========================================
>
> and I have such piece of code:
>
> ===========================================
> %rez = func1;
> $val = $rez{two};
>
> print $val;
> ===========================================
>
> I want to avoid using %rez in second piece of code, parse output of
> func1 in one step.
>
> How?
See perldsc, perlref.
#!/usr/bin/perl
use strict;
use warnings;
sub func1 {
my %rez = ( one => '1st'
, two => '2nd'
, seven => '7th'
);
return \%rez;
}
my $val = func1 -> {'two'};
print "$val\n";
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>