Jarrod Ramsey wrote:

> This is a pain for me to deal with, maybe its my method or the way I'm
> reading the file, but when I open a file, it reads only every 4th line.  The
> way I thought it was set up, it should only read one line at a time.  Please
> look at the code below and help me out if you can.
> 
> I've tried it several ways, and this one happens to be the last one I tried.
> Any help would be useful.
> 
> ( my(@allFiles) = readdir(DIRHND) ) || ( LogEntry(statslog, "Couldn\'t read
> $userpts: $!") ); 
> foreach $file (@allFiles) {
>       my($sBody);  my($a);
>       $file = "$userpts\\$file";
>       print "$file\n";
>       next unless ( open(FIL, "$file"));  ## I watched the code execute
> and this statement actually gets the first line.
>       $sRecp = <FIL>;                         ## whereas this one gets the
> second line.
>       while (<FIL>) {                         ## this one the third
>               $sBody .= <FIL>;                        ## this one the
> fourth
>       }
>       print $sBody;
>       chomp($sRecp);
>       close(FIL);
> }
> closedir(DIRHND);


Your code is confusing at best.  What is it doing ?
It appears to strip the first line and print the rest of the file.
Parts are missing also (like opendir, etc.).

Try this:

opendir DIRHND, $userpts or die "opendir: $!\n";

my @allFiles = readdir DIRHND or
   LogEntry (statslog, "Couldn't read $userpts: $!");

foreach (@allFiles) {

        my $file = "$userpts/$_";
        print "$file\n";

        open FIL, $file or die "Error opening $file: $!\n";
        $sRecp = <FIL>;         # eat first line
        chomp $sRecp;
        my @sBody = <FIL>;      # eat rest of file
        print @sBody;
        close FIL;
}
closedir DIRHND;

-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to