In your test you are using numeric == vs eq string comparsion for one thing. 
Also switch the print to:
        print OUTFILE1 $rec;

Wags ;)

-----Original Message-----
From: Mark Weisman [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 03, 2001 11:09
To: 'Beginners@Perl. Org (E-mail)'
Subject: Array with selected records.


Hello all:
  Hey I'm wanting to populate an array with only select records, but I'm
not sure how (more importantly when) to use a comparison piece. Please
help me if you can:

Open (INFILE, "<something.txt")
        Or die "Error opening something.txt. $!, stopped";
@records = <INFILE>
close(INFILE);
foreach my $rec (@records) {
        chomp($rec);
        ($val, $val1, $val2, etc.....) = split(/,/, $rec);

This is my opening and building the array from a text file. However what
I want to be able to do, is open the text file, then separate out the
records based on one value (example $val1) and build another text file
based on just the records that match the criteria.

Open (INFILE, "<something.txt")
        Or die "Error opening something.txt. $!, stopped";
@records = <INFILE>
close(INFILE);
foreach my $rec (@records){
        open (OUTFILE1, ">firstchoice.txt")
                or die "Error opening firstchoice.txt. $!, stopped";
        if ($val1 == "Bill Smith")
                print $rec (OUTFILE);
        }
}

I'm loosing my mind here, I just want the records that match the
criteria to be dumped into the OUTFILE. Any and all assistance would be
greatly appreciated.

Thank you,
Mark


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to