Your item 1 is so simple, I wonder how you can know anything at all about perl and not know how to do that -- three minutes or less with any man page about regexes would answer the question. The solution in a previous reply should suffice.

Your item 2 does not strike me as a regex problem. You presumably have a file name from an upload request, and a directory path where the upload should be stored. The "-f" function with a "path/name" arg will tell whether the file name exists in the directory: if ( -f "$path/$file" ). If that's true, you append a number to the file name and check again. If necessary, increment the number, append to the original file name and check again; repeat until "-f" returns false. (UPDATE: derby's suggestions above are much better -- use that instead.)

It's appalling that you've wasted a lot of time complaining about replies that "waste your time" by asking you to show what you've tried, and after all that, you apparently still have not tried anything yourself -- at least, you haven't given any evidence of having tried. So stop whining and try something. Learn by doing.

UPDATE: Actually, I'm curious about why you posted your question 1 here in the first place. It seems remarkably similar to another thread that you posted here a year ago. Did you really completely forget the advice given back then, or did you never understand it?


In reply to Re: Need 2 Regex's by graff
in thread Need 2 Regex's by BlenderHead

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.