thats great John... thanks a lot ....
u almost got my question...
but a few ellaborations of my posting,
1. the file should not be inside the program, its read with the given location as in my program.
2. the file doesnt contain the line number.
3. we dont know the exact number of arguments which will be passed. (in ur program 1..6)
4. Phrase 1, Phrase 2... was jus an example, it could be anything. for eg:
total Laptops produced: 60
total mice produced: 40
total cpu sold : 57
total printers produced: 98
total monitors produced: 10
.......................
phrases like these could be present any number of times in the file. but our function should search in the order the phrases are passed.
actually the phrase passed will be like, for eg "total cpu sold :" but it shud return the whole line, cuz the value 57 is important.
to give u clear idea...
the file " test.txt" contains:
total Laptops produced: 60
total cpu sold : 57
total mice produced: 40
total cpu sold : 45
total Laptops produced: 68
total mice produced: 48
total cpu sold : 51
total printers produced: 19
total monitors produced: 149
-------
for eg: this is given
$a= "total Laptops produced:";
$b ="total mice produced:";
$c = "total cpu produced:";
&search_phrase($filename, $a, $b, $c);
this function shud return 45.
i thank u again for ur support...
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.