Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl6: First array element places into string, 2nd fails to place into string

I'm trying to make a new string from array elements thus:

my $truth = "s3://dir/@d[$d1]/$plate/@d[$d1].$plate.delta";

but the issue is that this gives

s3://dir/pgr_9/1/@d[0].1.delta

when it should give

s3://dir/pgr_9/1/pgr_9.1.delta

Why isn't this array element @d[0] interpolating into the string $truth? How can I get it to?

like image 457
con Avatar asked Mar 01 '19 21:03

con


Video Answer


1 Answers

Not sure about the reason (probably $plate.delta is regarded as a method call?), but escaping the dot before delta solves the problem.

my $plate = 1;
my $d1 = 0;
my @d;
@d[0] = "pgr_9.1";

say "s3://dir/@d[$d1]/$plate/@d[$d1].$plate\.delta";

Output:

s3://dir/pgr_9.1/1/pgr_9.1.1.delta
like image 160
Eugene Barsky Avatar answered Nov 15 '22 10:11

Eugene Barsky