Hello Monks , I am new to perl , I have a small question here : I have an input file that look like this :
profile FIRSTGRADE
location here
age 23
color brown
sport n/a
firstname Amy
lastname Cako
middlename M
school n/a
job n/a
END
profile SECONDGRADE
location there
age 24
color white
sport n/a
firstname James
lastname Don
middlename M
school n/a
job n/a
END
profile THIRDGRADE
location here
age 29
color brown
sport n/a
firstname Amy
lastname Mando
middlename S
school n/a
job n/a
END
from my perl script I will be giving the profile name for example SECONDGRADE , then I will have to open that file and read to
get the firstname lastname and middlename for the person in the SECONDGRADE which in this case will be :
firstname : James
lastname : Don
middlename : M
the order within the input file might change line before the other . Can someone help?
open ( input , "<input.doc" ) or die " couldn't ";
while (<input>)
{
if(m/$grade/) { $subLine = $_ }
}
# not sure
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.