On Aug 31, [EMAIL PROTECTED] said: >Well if all you want to do is count the number of lines in the file then >zero out the file, the easiest way that I can think of would be to use a >couple of system calls like this.
No, there is no reason to make any system calls at all. open FILE, "< $file" or die "can't read $file: $!"; 1 while <FILE>; my $lines = $.; close FILE; That's one of a couple ways to do it. The code you've posted has NUMEROUS errors. >$logfile = myfile.txt; You should have quoted that. >$numlines = system(`cat $logfile |wc -l`)|| die "Cannot get number of >lines\n"; That doesn't work at all. You've combined system() with ``, and on top of that, you're using || with system(), which is the wrong logical operator to use. chomp(my $lines = `cat $logfile | wc -l`); That works, but it's still more work that it's worth. You can't use system() for this task, because it does NOT return the output of the command to you. >system(`cp /dev/null $logfile`) || die "Cannot zero load file\n"; Again, same errors. And when you DO use system(), you want to use && instead of ||: system("some system command") && die "system failed: $!"; or else system("some system command") == 0 || die "system failed: $!"; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ % -- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>