in reply to Re^2: If Exists in an Array?
in thread If Exists in an Array?

Thanks so much - this is going to work great. I have one other question. My source file just because of the way it is built - the $field1 value has leading spaces, how can I remove them on the fly?
Source Example: sx, 8849, sample1, source2 st, 893, sample2, source3 Matching Table: 8849 893
With the leading white space the match does not hit. Thanks Again, Ad.

Replies are listed 'Best First'.
Re^4: If Exists in an Array?
by keszler (Priest) on Nov 13, 2009 at 17:10 UTC
    Assuming that your example pertains to this:
    ($RR_Name,$Loco_no,$Event_Date,$Event_Time,$Event_Code,$Event_Duration +,$Source_File)=split(/,/,$record);

    You're currently splitting on just the comma, so the spaces are retained. To lose the lead/trail spaces just change your split:

    ($RR_Name,$Loco_no,$Event_Date,$Event_Time,$Event_Code,$Event_Duration +,$Source_File)=split(/[ ,]+/,$record); # + ^ ^^