I am a new subscriber and I do know a little perl, but I am trying to pick up a lot more very quickly. I am having an issue with a conditional checking a regular expression
that doesn't make sense and every book or online resource I have found
shows the same syntax I have.
Script background: I have one file of 4 letter codes (e.g. PART, PBIO, PENG), one code per line. I read this file into an array.
I have another file of pipe delimited data, in which one of these fields may include a code from the previous file or - for NULL. This file is too large to read in all at once, so I am reading it in line by line. The problem I am having is with this section:
while (<SIRSI>) { $temp = $_; $counter = $counter + 1; print "$counter \n"; foreach $code (@fundcodes) { if ($temp =~ /$code/) { print "$temp \n"; push(@fund_array, $temp); last; } } }
@fundcodes is the array of codes read in from the first file $counter is just for my debugging purposes.
The problem is that the code above thinks every line has $code in it. But when I hard-code PBIO instead of $code in the if conditional, I only get those files with PBIO.
Now, a secondary problem, which I also haven't figured out is how do I get only those lines that have a code between two pipes and not lines that also happen to have a code that can be used in a word (e.g. PART or PACT)?
Is there an easier way for me to do this?
Thanks, Tim
-- Tim McGeary [EMAIL PROTECTED]
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]