in reply to add a character at the end of a string
$string =~ s|/?$|/|;
although there are countless other ways. This one works by matching a trailing slash (if there is one) and 'replacing' it with a new trailing slash.
an alternative would be as follows..
$string .= '/' if $string !~ m|/$|;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: add a character at the end of a string
by rsennat (Beadle) on Dec 13, 2005 at 11:37 UTC | |
by reasonablekeith (Deacon) on Dec 13, 2005 at 11:49 UTC |