Re: seek(FH, 0,0) not working
Hi Mohapatra,
The idea of seek after while loop worked fine. Thanks for your help.
Regards,
Ganesh
TapasranjanMohapatra wrote:
-----Original Message-----
From: N. Ganesh Babu [mailto:ganesh@xxxxxxxxxxxxxxxxxxxxx]
Sent: Mon 5/9/2005 10:27 AM
To: Perl Beginners List
Subject: seek(FH, 0,0) not working
Dear All,
In the attached file, the date is present in the last line. My
requirement is to capture the date and fill it in the date field from
the line 1. after capturing the date through regular expression I am
using seek(FH,0,0) to goto the beginning of the file. But it has no effect.
My code is like this.
while($line=<FH>)
{
if($line=~m/Printed on Sat ([a-z]{3}\s*\d{1,2}\s*\d{4})/i)
{
$date=$1;
}
seek(FH,0,0)
$line=~s/\|\d{3}.................$date.............;
}
But this code is not giving the required result. Please help me in
solving this problem.
Regards,
Ganesh
Ganesh,
The substitution string is not proper. What you want to do? Just printing to STDOUT or writing to the file itself? If writing to file Have you opened the file for writing also?
If you dont need to process other lines of file, you should break from while loop and after that do a seek.
HTH
tapas
.
Relevant Pages
- Re: Database access sucks!
... writing your own Printing and Query Framework. ... Regards, ... (microsoft.public.dotnet.general) - Re: GSM AMR on blackfin.
... Akshay Mishra wrote: ... Best regards, ... time operation on a Blackfin DSP on the 533 evaluation board. ... I capture ... (comp.dsp) - Re: mr.rapidan says hi / music blogs
... I know that this kind of writing is tough. ... attempt to capture the essense of the musical expereience in words. ... hadn't really captured the soaring experience in any meaningful way. ... but her comment on my reflections was most telling. ... (rec.music.gdead) - Re: 1 step or many lines?
... > I'm wondering how most developers think when coding with regards ... Unless you're writing in APL, ... (microsoft.public.vb.general.discussion) - www.whois.net - no idea where to start
... capture the information and start a consolidation project in regards to ... Right now they all use different DNS sources and we are ... I have no idea where to start in regards to this but I am looking for some ... (microsoft.public.scripting.vbscript) |
|