Re: display tail of monster file

2009-09-27 Thread Harry Putnam
叶孤城  writes:

> 2009/9/27 叶孤城 :
>> 2009/9/27 Harry Putnam :
>>> Will it make any difference in loading time or cpu resource usage to
>>> use the `tail' command like 'qx/tail -n30 $file/' as apposed to something
>>> in straight perl like this example that prints the last 30 lines of $log:
>>>
>>
>> Not absolute that which is better.
>> But `tail` will launch an external process that is generally slower.
>> You may benchmark them to see the difference, using the module like:
>>
>
> very sorry, copy a wrong link, the correct one:
>
> http://search.cpan.org/~dcoppit/Benchmark-Timer-0.7102/lib/Benchmark/Timer.pm

Thanks for the link.  After looking there... it appears the module
concerns itself with timing.  I wondered if timing will also tell you
about system resource use.  


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: display tail of monster file

2009-09-26 Thread 叶孤城
2009/9/27 叶孤城 :
> 2009/9/27 Harry Putnam :
>> Will it make any difference in loading time or cpu resource usage to
>> use the `tail' command like 'qx/tail -n30 $file/' as apposed to something
>> in straight perl like this example that prints the last 30 lines of $log:
>>
>
> Not absolute that which is better.
> But `tail` will launch an external process that is generally slower.
> You may benchmark them to see the difference, using the module like:
>

very sorry, copy a wrong link, the correct one:

http://search.cpan.org/~dcoppit/Benchmark-Timer-0.7102/lib/Benchmark/Timer.pm

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: display tail of monster file

2009-09-26 Thread 叶孤城
2009/9/27 Harry Putnam :
> Will it make any difference in loading time or cpu resource usage to
> use the `tail' command like 'qx/tail -n30 $file/' as apposed to something
> in straight perl like this example that prints the last 30 lines of $log:
>

Not absolute that which is better.
But `tail` will launch an external process that is generally slower.
You may benchmark them to see the difference, using the module like:

http://search.cpan.org/~pangj/Net-Squid-ReverseProxy-0.02/lib/Net/Squid/ReverseProxy.pm

//ye

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




display tail of monster file

2009-09-26 Thread Harry Putnam
Will it make any difference in loading time or cpu resource usage to
use the `tail' command like 'qx/tail -n30 $file/' as apposed to something
in straight perl like this example that prints the last 30 lines of $log:

  #!/usr/local/bin/perl 
  
  use strict;
  use warnings;
  
  my $log = shift;
  
  print rb($log);
  
  sub rb {
use File::ReadBackwards;
my $log = shift;
my (@ar,$logline);
  
my $bw = File::ReadBackwards->new( "$log" ) or
 die "can't read <$log>: $!" ;  
  
my $cnt = 0;
while( defined( $logline = $bw->readline ) ) {
  $cnt++ if($logline);
  if($cnt <= 30) {
push @ar,$logline;
  }else{
last;
  }
}
## reverse @ar
return reverse @ar;
  }
  




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/