> -----Original Message----- > From: Paul Kraus [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 06, 2002 4:50 PM > To: 'Bob Showalter'; 'Perl' > Subject: RE: Seek tell > >
suggest you add: use Fcntl qw(:seek); then you can use the SEEK_* constants to make your code more readable. > open FILE, "<$filename" or die "Couldn't open $filename : $!\n"; > seek (FILE,0,2); > for($i=-2048;1;$i-=2048){ > seek (FILE,$i,1); > $/=undef; > $data=<FILE>; Reading the file moves the pointer. Since you undef'ed $/, the pointer will be at EOF after this statement. > if ($data=~m/\f([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9])/){ > $pos=tell (FILE); This is always at EOF. You need to call tell() before you read from the file (i.e. right after the seek above). > print "$pos --pos\n"; > last; > } > } > seek (FILE,$pos,0); > $/=undef; > $end=<FILE>; > print "$end\n"; > > > -----Original Message----- > > From: Bob Showalter [mailto:[EMAIL PROTECTED]] > > Sent: Friday, December 06, 2002 4:44 PM > > To: 'Paul Kraus'; Perl > > Subject: RE: Seek tell > > > > > > > -----Original Message----- > > > From: Paul Kraus [mailto:[EMAIL PROTECTED]] > > > Sent: Friday, December 06, 2002 4:42 PM > > > To: Perl > > > Subject: Seek tell > > > > > > > > > I am reading through a file. > > > I am testing it for a regexrp. If expr is true then I save > > the pos of > > > the file to a variable using tell. > > > > > > But it always the eof position an not the position directly > > before the > > > match. Any thoughts? > > > > Time to post your code :~) > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]