Right here's the problem:
i have one file (input), which contains keywords to be matched and solution.java is the file i want to check through for the keywords.
so far i have written a program that will look at the first line (ie keyword) in input and loop through solution.java to see if it exists. the second line in input (ie 2nd keyword) is then used to search through everyline of solution.java to see if it exists. this continues for all lines in input.
so my program will print out "yes the", $keyword, " exists";
for every line it is found in solution.java.
this is great but a counter would be far more useful.
if i know how many lines there are in input it is easy to create $counter 1, $counter2 etc for each line. the problem comes as the number of lines of input can vary. So i need a way to create a separate counter for each line in input.
i hope i havent lost anybody and any help would be gratefully received
below is my current loop, HTH
#####################
# lines is solution.java
# lines2 is input
for ($a=0; $a<$#lines+1; $a++){
for ($b=0; $b<$#lines2+1; $b++){
if ($lines[$a] =~ /$lines2[$b]/) {
print $lines[$a];
print "\nyes ", $lines2[$b], " exists\n\n";
}
}
}
#####################
cheers Stort
2006-02-21 Retitled by g0n, as per Monastery guidelines
Original title: 'arrays and variables'
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.