Skip to content

Commit 0752731

Browse files
committed
Another solution for run «…» trap
And some clarified comments.
1 parent 45d68ff commit 0752731

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

doc/Language/traps.pod6

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,16 @@ my $y = ‘foo bar’;
562562
563563
my %h = $x => 42, $y => 99;
564564
say %h«$x»; # ← WRONG; assumption that $x has no whitespace
565-
say %h«$y»; # ← WRONG; this time you can clearly see how wrong it is
565+
say %h«$y»; # ← WRONG; splits ‘foo bar’ by whitespace
566566
say %h«"$y"»; # ← KINDA OK; it works but there is no good reason to do that
567567
say %h{$y}; # ← RIGHT; this is what should be used
568568
569569
run «touch $x»; # ← WRONG; assumption that only one file will be created
570-
run «touch $y»; # ← WRONG; this time you can clearly see how wrong it is
571-
run «touch "$y"»; # ← WRONG; still an error if $y starts with -
570+
run «touch $y»; # ← WRONG; will touch file ‘foo’ and ‘bar’
571+
run «touch "$y"»; # ← WRONG; better, but has a different issue if $y starts with -
572572
run «touch -- "$y"»; # ← KINDA OK; it works but there is no good enough reason to do that
573573
run ‘touch’, ‘--’, $y; # ← RIGHT; explicit and *always* correct
574+
run <touch -->, $y; # ← RIGHT; < > are OK, this is short and correct
574575
=end code
575576
576577
Basically, C<«»> quoting is only safe to use if you remember to

0 commit comments

Comments
 (0)