Yes:

seek HANDLE, 0, 0;

Resets the file pointer to the beginning.

Aloha => Beau.

-----Original Message-----
From: Paul Kraus [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 4:37 AM
To: Perl
Subject: Restarting at top of file


I want to read through a file and the read through it again. However the
only way it seems to work for me is if I open the file, Read the file,
Close the file, and the reopen it. Is there a way to do this with out
having to run the open command twice?

Does not work
--------------
open PEL, "vend.csv";
my (%dup,%vend);

foreach (<PEL>){
  chomp;
  @temp=split /,/,$_;
  $_=~s/ //g foreach (@temp);
  $dup{$temp[1]}++;
}

foreach (<PEL>){
  chomp;
  @temp=split /,/,$_;
  print  "$_\n" foreach (@temp);
  $_=~s/ //g foreach (@temp);
  $vend{$temp[1]}=$temp[0];
}


Does Work
---------
open PEL, "vend.csv";
my (%dup,%vend);

foreach (<PEL>){
  chomp;
  @temp=split /,/,$_;
  $_=~s/ //g foreach (@temp);
  $dup{$temp[1]}++;
}
open PEL,"vend.csv";
foreach (<PEL>){
  chomp;
  @temp=split /,/,$_;
  $_=~s/ //g foreach (@temp);
  $vend{$temp[1]}=$temp[0];
}


Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax
www.pelsupply.com




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

Reply via email to