John W. Krahn wrote:
Brian wrote:

my @pages = (
    "lc1",
    "lc2/",
    "lc3/index.html",
    "lc4/",
    "lc5",
);

map {s/(some regex here)/$1\//} @pages;

$ perl -le'
my @pages = (
"lc1",
"lc2/",
"lc3/index.html",
"lc4/",
"lc5",
);
print "@pages";
s|(?<!/)\z|/| for @pages;
print "@pages";
'
lc1 lc2/ lc3/index.html lc4/ lc5
lc1/ lc2/ lc3/index.html/ lc4/ lc5/

$ perl -le'
my @pages = (
"lc1",
"lc2/",
"lc3/index.html",
"lc4/",
"lc5",
);
print "@pages";
s|(?<!/)(?<!html)\z|/| for @pages;
print "@pages";
'
lc1 lc2/ lc3/index.html lc4/ lc5
lc1/ lc2/ lc3/index.html lc4/ lc5/




John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to