Perl6, how to remove the last character in a string?

  • A+
Category:Languages

In Perl6, how does one remove the last character from a string?


My Perl6 notes on how to remove the last letter of a string:

$ perl6 -e 'my $x="a b c d "; $x = chop( $x ); say "<$x>";' <a b c d>   $ perl6 -e 'my $x="a b c d "; $x ~~ s/" "$//; say "<$x>";' <a b c d> 

Note $ means to match at the end of the string

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: