in reply to using s/// to remove file extensions
With wildcards, * is definitely "zero or more of any possible character including the space."
With regular expressions, * is "zero or more of the last token"
Your last token before the * is [A-Z]; hence, you'r [A-Z]*.pdf matches things like:
...but not something like file.pdf, for instance.
So regarding your regex, what you really wanted was [A-Z].*\.pdf... you see, a "." means (in Perl's regular expressions), "any single character except for the newline." (this is also why you have to escape the following dot, the one separating the filename from the extension)
Also, your right-hand side of the substitution won't work... that's going to name the file, literally, [A-Z]*
Instead, you have to capture the filename in a special variable (with brackets) and use that variable (in this case it's going to be $1, because it's going to be the first bracket counting from the left). You do it like this:
s/([A-Z].*)\.pdf/$1/;
There. Your filename, without the extension.
frodo72's solution is, however, better (and there are others, of course), but this is what you were trying to do, corrected.
|
|---|