I am trying to reverse engineer two scripts that my perl programming book gave me but I can't find explanations in the book (I am sure they are there, but I am not having any luck) for some of the special characters.
The first script is:
while (<STDIN>) {
if (/a/i && /e/i && /i/i && /o/i && /u/i) {
print;
}
}
My question for the above script is what is the i outside of each of the // symbles.
The second script is:
hile (<>) {
print if
(/^[^aeiou]*a[^eiou]*e[^aiou]*i[^aeou]*o[^aeiu]*u[^aeio]*$ );
}
For this script I have a few more questions. It is supposed to parse a statement in order to determine if it shows each of the vowels in order. Why couldn't one just do this /a*i*o*u*/. Also what does e
^aiou actually look for? e with any vowel character after it? Last, what is the purpose of the $ sign. I found this code very confusing. Thanks for your help!
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.