Re: re-reading from already read file handle

2012-09-02 Thread Dr.Ruud
On 2012-08-20 22:39, Rajeev Prasad wrote: just want to find out in how many records string was found: my $count=0; seek $tmp_FH,0,0; while (<$tmp_FH>) { my $line=$_;chomp($line); if ($line=~m/\"$str\"/) {$coun

Re: re-reading from already read file handle

2012-08-20 Thread Bill Stephenson
On Aug 20, 2012, at 7:24 PM, John SJ Anderson wrote: > On Monday, August 20, 2012 at 4:15 PM, Rob Dixon wrote: >> >> This question is double-posted on Stack Overflow >> > So what? I don't see anything in the list FAQ about cross-posting questions > to other resources, just about cross-posting a

Re: re-reading from already read file handle

2012-08-20 Thread John SJ Anderson
On Monday, August 20, 2012 at 4:15 PM, Rob Dixon wrote: > > This question is double-posted on Stack Overflow > So what? I don't see anything in the list FAQ about cross-posting questions to other resources, just about cross-posting across the different beginner mailing lists. john. -- John

Re: re-reading from already read file handle

2012-08-20 Thread Rajeev Prasad
, August 20, 2012 6:15 PM Subject: Re: re-reading from already read file handle Rajeev Prasad wrote: >I opened a file to read from line by line. > > >open(FH,"<","$myfile") or die "could not open $myfile: $!"; >while () >{ >...do somethin

Re: re-reading from already read file handle

2012-08-20 Thread Rob Dixon
Rajeev Prasad wrote: >I opened a file to read from line by line. > > >open(FH,"<","$myfile") or die "could not open $myfile: $!"; >while () >{ >...do something > >} > >later on in program, try to re-read the file (walk thru the file >again): >while () >{ >...do something > >} > >and realized tha

Re: re-reading from already read file handle

2012-08-20 Thread Jim Gibson
On Aug 20, 2012, at 3:32 PM, Rajeev Prasad wrote: > Thx. I did some timestamp prints from within script, this piece is taking too > long: almost 5 minutes to complete...!!! > > fyi, the strArr array contains about 1500 string elements. (this loop runs > that many times) > the file tmp_FH_SR i

Re: re-reading from already read file handle

2012-08-20 Thread Rajeev Prasad
PM Subject: Re: re-reading from already read file handle On Aug 20, 2012, at 1:39 PM, Rajeev Prasad wrote: > thank you. seek did the job. > > by the way can this be made any better? > > just want to find out in how many records string was found: > >            my $count=0

Re: re-reading from already read file handle

2012-08-20 Thread Jim Gibson
On Aug 20, 2012, at 1:39 PM, Rajeev Prasad wrote: > thank you. seek did the job. > > by the way can this be made any better? > > just want to find out in how many records string was found: > > my $count=0; > seek $tmp_FH,0,0; > while (<$tmp_FH>) >

Re: re-reading from already read file handle

2012-08-20 Thread Shawn H Corey
On Mon, 20 Aug 2012 13:39:16 -0700 (PDT) Rajeev Prasad wrote: >             my $count=0; >             seek $tmp_FH,0,0; >             while (<$tmp_FH>) >             { >                 my $line=$_;chomp($line); # Please put each statement on its own line >                 if ($line=~m/\"$str\

Re: re-reading from already read file handle

2012-08-20 Thread Rajeev Prasad
($line=~m/\"$str\"/) {$count++;}        #in the file $str string would be in quotes             } From: Andy Bach To: Rajeev Prasad Cc: perl list Sent: Monday, August 20, 2012 2:10 PM Subject: Re: re-reading from already read file handle

Re: re-reading from already read file handle

2012-08-20 Thread Shawn H Corey
On Mon, 20 Aug 2012 12:00:55 -0700 (PDT) Rajeev Prasad wrote: > open(FH,"<","$myfile") or die "could not open $myfile: $!"; # You should used a my variable for the file handle open(my $fh,"<","$myfile") or die "could not open $myfile: $!"; > while () # with the my variable file handle while (<

Re: re-reading from already read file handle

2012-08-20 Thread Andy Bach
On Mon, Aug 20, 2012 at 2:00 PM, Rajeev Prasad wrote: > is this default behaviour? how to work around this? file is big and I do not > want to keep in memory as array. so is my only option is to close and open > the file again? Yes, that's the default. "seek" lets you reset things though perldo