NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Death to .* (Score:1)
Re:Death to .* (Score:1)
How, pray tell, is this particular regex going to backtrack needlessly? Or are you just cargo culting the “death to dot star” line?
(That said, the
.*in Robrt’s pattern is superfluous, as the pattern will match the exact same things with or without it.)Re:Death to .* (Score:1)
.*at the end was superfluous. He could have put them at both ends:/.*\._.*/. So, yes, I was cargo culting it. I was trying to draw attention to the fact that.*is almost never what you want to use.Re:Death to .* (Score:1)
“Death to dot star” is about backtracking. At the end of the pattern, the
.*won’t backtrack. If you put another one at the front, though, it will. What is your point?You would have made your case much better if you just said “the
.*there is a noop” instead of throwing in something entirely unrelated that happens to be about dot star.But you’re wrong. It is exactly what you wa
Re:Death to .* (Score:1)
Err, that is supposed to be a
=~there of course.I think I know (Score:1)
Let me guess: it has to do with removing those resource fork files that you get on OS X in some circumstances?
Re:I think I know (Score:2)
Re:I think I know (Score:2)
Re:I think I know (Score:2)
Re: Line Noise (Score:1)
It’s not Perl that’s line noise, it’s the regex syntax. Last night I wrote this:
s{/(?!\.\.)[^/]+/+\.\.(?=/|\z)}{}gRe: Line Noise (Score:2)
So it cleans up pathnames to remove
/foo/../bar/../bazto be juRe: Line Noise (Score:1)
Even
/xonly really helps because of your profuse comments, though.You guessed correctly: I needed to normalize HTTP URIs to compare them, and URI [cpan.org]’s
canonicalmethod doesn’t finish the job. To be precise, this runs in a1 while s///loop, which is necessary to handle paths likefoo/bar/baz/quux/../../../bar.Re: Line Noise (Score:2)
-Dom
Re: Line Noise (Score:1)
Hmm, actually, that has a bug. The negative look-ahead must contain a trailing slash, otherwise the pattern will erroneously fail to match something like
foo/..fooledya/../bar.At first I thought I needed a more complex assertion than just include a trailing slash in there, so I started rewriting the regex extensively, and after I realised that it’s not that complex, I noticed that my comments actually have a noticably different focus from yours, so I decided to keep the result for comparison: