*SOLVED*
I have a problem with my Perl coursework. Hope someone can help.
I need a regular expression which accepts a filename as a argument.
The conditions for the file name are;
* No greater than 8 characters in length
* No file extension allowed
* At least 3 characters
* Must start with a letter, all though digits are permitted for characters other than the first again.
Here is my
incomplete failed attempt. :(
while ($FileStr !~ m/(^[a-zA-Z])\w{2,5}/) {<br><br>
print ("Please input a valid filename:");<br>
$FileStr = <STDIN>;<br>
chomp ($FileStr);<br>
$x = length($FileStr);<br>
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.