But in Perl 5 `.` is string concatenation operator, not `+`

On 2017-01-13 09:33:10 GMT, Todd Chester wrote:
>>
>> On Fri, Jan 13, 2017 at 10:01 AM, Todd Chester <toddandma...@zoho.com 
>> <mailto:toddandma...@zoho.com>> wrote:
>>
>>     Hi All,
>>
>>     I am trying to understand how to read variables from the
>>     shell's environment.  I am reading this:
>>
>>     https://docs.perl6.org/language/variables#Dynamic_variables
>>     <https://docs.perl6.org/language/variables#Dynamic_variables>
>>
>>     <code>
>>     #!/usr/bin/perl6
>>     # print "Display = " + %*ENV{'DISPALY'} + "\n";
>>     print "Perl Version = " + $*PERL + "\n";
>>     </code>
>>
>>
>>     $ ./env.pl6
>>     Cannot resolve caller Numeric(Perl: ); none of these signatures match:
>>         (Mu:U \v: *%_)
>>       in block <unit> at ./env.pl6 line 3
>>
>>
>>     What am I missing?  I'd like to get the one I commented
>>     out on line 2 working too.  That gives me the following error:
>>
>>     Use of uninitialized value of type Any in numeric context
>>       in block <unit> at ./env.pl6 line 2
>>     Cannot convert string to number: base-10 number must begin with
>>     valid digits or '.' in '⏏Display = ' (indicated by ⏏)
>>       in block <unit> at ./env.pl6 line 2
>>
>>
>>     Many thanks,
>>     -T
>>
>>
>>
>>
>> -- 
>> Fernando Santagata
>
> On 01/13/2017 01:20 AM, Fernando Santagata wrote:
>> Try:
>>
>> print "Perl Version = " ~ $*PERL ~ "\n";
>>
>> or better:
>>
>> say "Perl Version = $*PERL";
>>
>> OTH
>
>
> Hi Fernando,
>
> That fixed it.  I was using Perl5's string concatenation.  Will "~"
> always replace "+" for this, or only with a dynamic variable?
>
> On line two, I misspelled "DISPLAY".
>
> <code>
> #!/usr/bin/perl6
> print "Display = " ~ %*ENV{'DISPLAY'} ~ "\n";
> print "Perl Version = " ~ $*PERL ~ "\n";
> </code>
>
> ./env.pl6
> Display = :0.0
> Perl Version = Perl 6
>
>
> Thank you!
> -T

Reply via email to