s/// doesn't work like that. In s/PATTERN/REPLACEMENT/ the PATTERN in a regular expression, like the one you've given, but the REPLACEMENT part isn't. The replacement is just a string use like a regular double-quoted string. The /e makes the string evaluate, i.e. act like code instead of a piece of chars and [A-Z]* isn't valid Perl code. So remove the e, don't use a pattern in the replacement part, and ultimately fix your pattern. That might include capturing a part of the match matched by PATTERN, and you then interpolate that match in the replacement part (as the replacement is just a double-quoted string). What you really want to have, I think, is

$file =~ s/^([A-Z].*)\.pdf\z/$1/;
Now this introduce quite a few things, like ^, (), .*, \., \z, and $1. You can read more about them in perlretut and other documents that come with Perl. To learn about s/// see perlop.

Update: Didn't read closely enough; adjusted the pattern to fit the OP.

ihb

See perltoc if you don't know which perldoc to read!


In reply to Re: using s/// to remove file extensions by ihb
in thread using s/// to remove file extensions by Plotinus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.