in reply to Combining while statements
Example of tab delimited file:use Fcntl qw(:DEFAULT :flock); use CGI; use CGI::Carp qw(fatalsToBrowser);
20645 CJ Sports Sportswear and equipment retailer specialising +in rugby, hockey, netball and cricket. Full product details and o +rdering available online. www.cj-sports.co.uk/ 20660 Gekko Gear Selection of winter sports apparel. + www.gekkogear.com/
open (SIDX, "$data_dir/search.idx"); open (SIDX2, "$data_dir/search2.idx"); if ($file_locking ne "No"){flock (SIDX, LOCK_SH) or die "Can't set lo +ck for file: $data_dir/search.idx, $data_dir/search2.idx $!\n";} while (defined($line=<SIDX2>) and ($premiumline=<SIDX2>)) { $sline = $line, $premiumline; foreach $kwr (@skeyw, @premiumkeyw) { if (($sline =~ /$kwr/i) and ($kwr ne "")) { $toadk = "true"; } } if ($toadk eq "true") { $resultline[$icnt] = $line; $toadk = false; $icnt++; } } #if ($file_locking ne "No"){flock (CIT, LOCK_UN);} close (SIDX); close (SIDX2); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Assigning Flat Files to Arrays
by jeffa (Bishop) on Apr 27, 2004 at 05:45 UTC |