perlquestion
Anonymous Monk
Greetings Monks:<BR><BR>
I'm having a problem trying to pattern match. What I'm trying to do, is look through a file containing records, each record contains multiple XML tags. I want to find the record containing a tag that has data of a specific length (in this case, 58 characters).<BR><BR>
My basic code is:<BR>
<code>
# The filename should be the first arguement
$file = $ARGV[0];
# The search string should be the second arguement
$searchString = $ARGV[1];
$matchesFound = 0;
if (-e $file) {
open (INPUTFILE, "<$file") or die "Can't open $file for input.\n";
while ($record = <INPUTFILE>) {
$_ = $record;
if (/$searchString/g) {
print $record;
$matchesFound = $matchesFound + 1;
}
}
close INPUTFILE;
print "$matchesFound found.\n";
}
else {
print "$file doesn't exist.\n";
}
</code>
<BR><BR>
The problem is, that I'm not quite sure exactly what expression I should be feeding to the script. Is there a way to find, say, 58 matches of a alphanumberic or space?<BR><BR>
Thanks in advance for your help.
8