If you know what line the word is on and the file is in an array, you can work with that specific line. Let's say it's on line four and the file had been read into the array @file. To just work with line four, you'd have to work with the value $file[3]. Remember that Perl starts numbering line one as zero.
As for the location of the word on that line, if you know which word (in terms of the number of the word) it is, you can again make use of an array. Again, working with line four:
my @words = split(/\s/,$file[3]);
Perl numbers the first word as word zero, and so forth. So, if it were say, the ninth word, the value would be stored in $words[8].
If you don't know its position relative to other words, but do know that it's characters seven through ten on the line, for instance, you could make use of substr. Perl again starts the numbering at zero, so:
my $word = substr($file[3], 6, 3);
# The third argument to substr is the length of the string
If this doesn't help, clarify it a bit, and I'll see what I can do. Good luck. |