develooper Front page | perl.perl6.users | Postings from January 2019

Re: I need hash string help

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
January 12, 2019 02:12
Subject:
Re: I need hash string help
Message ID:
b1ef9e2c-ed97-5c96-da30-b61b47222d85@zoho.com
On 1/11/19 5:08 PM, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> Now what am I doing wrong?  I need to convert the value in a
> hash to a string:
> 
> $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => 
> "Larry" ); $y= %Vendors<ContactName>; say $y;'
> Type check failed in assignment to $y; expected Str but got Any (Any)
>    in block <unit> at -e line 1
> 
> 
> $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => 
> "Larry" ); $y= %Vendors<ContactName>.Str; say $y;'
> Use of uninitialized value of type Any in string context.
> Methods .^name, .perl, .gist, or .say can be used to stringify it to 
> something meaningful.
>    in block <unit> at -e line 1
> 
> 
> Many thanks,
> -T

Figured out my booboo. I had to change from

    $PartsStr =
       "Hi $Manager,<br><br>" ~
       "Account Number: <b>$AccountNo</b><br><br>" ~

to

    $PartsStr =
       "Hi " ~ $Manager ~ ",<br><br>" ~
       "Account Number: <b>" ~ $AccountNo ~ "</b><br><br>" ~

Thread Previous | Thread Next


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