I'm new to Perl, but it looks to me as if the line -- next NOSTOCK if $comp
ne 0;  -- is redundant.  Wouldn't the loop behave the same without that
line?
                Ed Ewen
                (404) 575-3531
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 


        -----Original Message-----
        From:   Greg Wardawy [SMTP:[EMAIL PROTECTED]]
        Sent:   Wednesday, April 26, 2000 5:24 PM
        To:     Perl-Win32-Users Mailing List
        Subject:        Re: Extracting lines

        Thanks Douglas,
        I'm reposting plain text:
        To: "Perl-Win32-Users Mailing List" 
        <[EMAIL PROTECTED]> Subject: Extracting
lines
        Hello all,
        I need to print just the lines where the fourth element is not a
member of 
        the second list so I wrote the following code:
        ####################
        #!perl -w
        open(NOSTOCK, "< nostock.csv") || die "can't open nostock.csv for
reading: 
        $_!";
        open(ORD, "< custord2") || die "can't open custord2 for reading:
$_!";
        open(CUST, "> cust") || die "can't create cust: $_!";
        my ($line, @ord, $i, $aref, @nostock, $bref, $n, $j);
        while ($line = <NOSTOCK>) {
        push @nostock, [ split ',', $line ];
        }
        while ($line = <ORD>) {
        push @ord, [ split ',', $line ];
        }
        ORD: for $i ( 0 .. $#ord ) {
        $aref = $ord[$i];
        $n = @$aref - 1;
        NOSTOCK: for $j ( 0 .. $#nostock) {
        $bref = $nostock[$j];
        $n = @$bref - 1;
        $comp = $aref->[4] cmp $bref->[0];
        last NOSTOCK if $comp eq 0;
        next NOSTOCK if $comp ne 0;
        }
        print 
        
"$aref->[0],$aref->[1],$aref->[2],$aref->[3],$aref->[4],$aref->[5],$aref->[6
],$aref->[7],$aref->[8],$aref->[9]" 
        if $comp ne 0;
        }
        close(NOSTOCK);
        close(ORD);
        close(CUST);
        ######################

        In what other ways (more efficient, faster or just different) can I 
        complete this task?

        Here are parts of my input files:
        # custord2:
        3,1000000005,R496055,348,PENFUZZY,11.99,1,04,25,00
        3,1000000005,R496055,348,RDPILOT,7.99,1,04,25,00
        3,1000000005,R496055,351,HOUWHERE,4.95,1,04,25,00
        3,1000000005,R496055,351,PENDINNER,6.95,1,04,25,00
        3,1000000005,R496055,351,RANONEFISH,8.95,1,04,25,00
        3,1000000005,R496055,351,SIMCHEERIOS,5.99,1,04,25,00
        3,1000000005,R496055,359,RANGREEN,8.95,1,04,25,00
        # nostock.csv:
        FNWDISPLAY,
        HAVCASTLE,
        HAVCONSTRUCTION,
        HAVEASYFAMILY,
        HAVMASTERCKDLX,
        MERNEWBAKING,
        MORHORSD,
        RANGREEN,
        RANONEFISH,
        STRSMALL,
        TLCELMOART,
        TLCLITTLEBEAR,
        TLCMADELINE,
        WARLITTLEMEALS,

        Thanks in advance.
        Greg




        ---
        You are currently subscribed to perl-win32-users as:
[EMAIL PROTECTED]
        To unsubscribe, forward this message to
                 [EMAIL PROTECTED]
        For non-automated Mailing List support, send email to  
                 [EMAIL PROTECTED]

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to