develooper Front page | perl.beginners | Postings from April 2002

Re: FW: How does one get returned values from embeded scalars

Thread Previous
From:
bob ackerman
Date:
April 1, 2002 09:07
Subject:
Re: FW: How does one get returned values from embeded scalars
Message ID:
F8E46601-4592-11D6-A2BF-003065428126@pacbell.net
looks like '$login = print $hosts{$hostname};'
is not what you want.
'print' function returns '1' -- not the string it prints.
you want:
$login = $hosts{$hostname};
and if you really want to print the value:
print $login;

On Monday, April 1, 2002, at 08:30  AM, J.Hourihane@cdcixis-cmna.com wrote:

> The problem I am having is with $full
> How do I get $login to return its value when I try to assign this scalar
> $full
>
> Thanks in advance
>
> #!/util/perl5.static
>
> $hostname = qx(/usr/ucb/hostname);
> chomp $hostname;
>
> %hosts = (
> 	crane => "hourihj",
> 	runner => "paulg",
> 	ice => "root",
> );
>
> $login = print $hosts{$hostname};
> chop $login;
>
> #print "$login\n";
> $full = qx(ypmatch $login passwd);
> print $full;
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About