On 1/11/19 5:59 PM, Tom Browder wrote:

On Fri, Jan 11, 2019 at 19:09 ToddAndMargo via perl6-users <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:

    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" );

Try eliminating “acme =>” for a starter.

-Tom

Hi Tom,

It was a shortened version of a lager has within a hash.

$ p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 } ); say %Vendors{$x}<ContactName> ~ "\t" ~ %Vendors{$x}<AccountNo>;'

$p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 } ); my Str $y = %Vendors{$x}<ContactName>.Str; say $y;'

I just shortened it to test syntax. I need the value of the hash to going into a string. It did but the error message I got back
confused the heck out of me.

      Type Str does not support associative indexing.

Made me think something was wrong with the hash.  The hash
and was fine.

I found it by disregarding the error message and looking for
ANYTHING I had changed.

My error turned out be `$var<br>` (HTML "Break") being mistaken
for something else in a string assignment.  Breaking the
variables apart with `$var ~ "<br>"` fixed it.

Thank you for the help anyway.  There is a lot of great folks
on this list.  :-)

-T




--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to