Re: trying to use IO::Handle

2008-04-14 Thread Richard Lee
Chas. Owens wrote: On Mon, Apr 14, 2008 at 12:50 AM, Richard Lee <[EMAIL PROTECTED]> wrote: snip my $start = qr/@{[ POSIX::strftime( '%b %e %H:', localtime time - ONE_HOUR ) ]}/; snip I will have to try out your POSIX solution as I have particular in adding space if date is s

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Richard Lee wrote: John W. Krahn wrote: Or you could do something like this: use POSIX (); use constant ONE_HOUR => 60 * 60; my $file_name = '/var/log/server.log'; my @bad = do { my $start = qr/@{[ POSIX::strftime( '%b %e %H:', localtime time - ONE_HOUR ) ]}/; open my $SOURCE, '<

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Mon, Apr 14, 2008 at 12:50 AM, Richard Lee <[EMAIL PROTECTED]> wrote: snip > >my $start = qr/@{[ POSIX::strftime( '%b %e %H:', localtime time - > > ONE_HOUR ) ]}/; snip > I will have to try out your POSIX solution as I have particular in adding > space if date is single digits (April 3 get

Re: trying to use IO::Handle

2008-04-13 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: You are not returning the contents of @bad and you are not passing in the name of the file to open so I assume that this is in a subroutine becaus

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 11:13 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Chas. Owens wrote: > > > On Sun, Apr 13, 2008 at 10:44 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > > snip > > > > does subroutine introduce additional delay? > > > All non-inlined subroutines introduce some delay, alth

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Chas. Owens wrote: On Sun, Apr 13, 2008 at 10:44 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip does subroutine introduce additional delay? All non-inlined subroutines introduce some delay, although that is not your problem as you are only calling it once. snip Perl has inlined subroutin

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 10:44 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > > does subroutine introduce additional delay? > > > > All non-inlined subroutines introduce some delay, although that is not your > problem as you are only calling it once. snip Perl has inlined subroutines now? Wh

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 9:21 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip > does subroutine introduce additional delay? snip Yes, there is a non-trivial amount of work done setting up a function call; however, since you are only calling it once that isn't a big deal. My rule of thumb for crea

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: You are not returning the contents of @bad and you are not passing in the name of the file to open so I assume that this is in a subroutine because you are calling it m

Re: trying to use IO::Handle

2008-04-13 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: You are not returning the contents of @bad and you are not passing in the name of the file to open so I assume that this is in a subroutine because you are calling it many times in your pro

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: You are not returning the contents of @bad and you are not passing in the name of the file to open so I assume that this is in a subroutine because you are calling it many times in your program? Yes, it is sub

Re: trying to use IO::Handle

2008-04-13 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: sub shove_it { my $start = time_this(scalar localtime( ( time() - ( 60 * 60 ) ) )); What does the time_this() function do? sub time_this { my $chunli = join(' ', ( split( /\s+/, $_[0]))[1,2,3]);

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: sub shove_it { my $start = time_this(scalar localtime( ( time() - ( 60 * 60 ) ) )); What does the time_this() function do? sub time_this { my $chunli = join(' ', ( split( /\s+/, $_[0]))[1,2,3]); if ($chunli =~ s

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 4:12 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > > > push @bad, "$3_$5_$4_$6_$2_$1"; > > > > > snip > > > > I believe they would come out roughly the same in terms of > > performance, but, in general, I don't trust $1, $2, etc outside of a > > substitution. I have

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Chas. Owens wrote: On Sun, Apr 13, 2008 at 3:20 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip Why not just: snip push @bad, "$3_$5_$4_$6_$2_$1"; snip I believe they would come out roughly the same in terms of performance, but, in general, I don't trust $1, $2, etc outside of a substitu

Re: trying to use IO::Handle

2008-04-13 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: sub shove_it { my $start = time_this(scalar localtime( ( time() - ( 60 * 60 ) ) )); What does the time_this() function do? sub time_this { my $chunli = join(' ', ( split( /\s+/, $_[0]))[1,2,3]); if ($chunli =~ s/^(\S\S\S)(\s)(\d\d\

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 3:20 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > Why not just: snip > push @bad, "$3_$5_$4_$6_$2_$1"; snip I believe they would come out roughly the same in terms of performance, but, in general, I don't trust $1, $2, etc outside of a substitution. I have been bi

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Chas. Owens wrote: On Sun, Apr 13, 2008 at 2:32 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip But I am not 100% sure what you are saying on " Why are you making sure the data is right and then pulling the data you want out? " ? I need to move onto next data if it doesn't conform to 2nd regex

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Chas. Owens wrote: On Sun, Apr 13, 2008 at 2:32 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip Or better, use the qr// operator to compile $start. perldoc -q /o snip I thought about suggesting qr//, but the source of $start is my $start = time_this(scalar localtime( ( time() - ( 60 * 6

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Richard Lee wrote: sub shove_it { my $start = time_this(scalar localtime( ( time() - ( 60 * 60 ) ) )); What does the time_this() function do? open my $source, "<", "/var/log/server.log" or die "Could NOT open /var/log/server.log: $!"; while ( <$source> )

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 2:32 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip > But I am not 100% sure what you are saying on " Why are you making sure the > data is right and then pulling the data you want out? " ? > I need to move onto next data if it doesn't conform to 2nd regex and then I > am

Re: trying to use IO::Handle

2008-04-13 Thread Richard Lee
Chas. Owens wrote: On Sun, Apr 13, 2008 at 2:05 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip next if ! /^$start/; snip You should say next unless /^$start/o; The o makes a promise that $start won't change, so the regex only gets compiled once (it is recompiling the rege

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Chas. Owens wrote: On Sun, Apr 13, 2008 at 2:05 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip next if ! /^$start/; snip You should say next unless /^$start/o; The o makes a promise that $start won't change, so the regex only gets compiled once (it is recompiling the regex each t

Re: trying to use IO::Handle

2008-04-13 Thread John W. Krahn
Richard Lee wrote: why does below fail? - where it's failing - open my $source, "<", "/tmp/server.log" or die "Could NOT open /var/log/server.log: $!"; $source is an opened filehandle. my $file = new IO::Handle; $file is an IO::Handle object but it is not rela

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 2:16 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: snip > >next if ! m{ > >.+\s+D\s+ > > udp\s+ > > \d+\.\d+\.\d+\.\d+\s+ > > \d+\.\d+\.\d+\.\d+\s+ > >

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 2:05 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip >next if ! /^$start/; snip You should say next unless /^$start/o; The o makes a promise that $start won't change, so the regex only gets compiled once (it is recompiling the regex each time through the loop

Re: trying to use IO::Handle

2008-04-13 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: why does below fail? - where it's failing - open my $source, "<", "/tmp/server.log" or die "Could NOT open /var/log/server.log: $!"; my $file = new IO::Handle; while ($_ = $file->getline($source) ) { --

Re: trying to use IO::Handle

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 1:35 PM, Richard Lee <[EMAIL PROTECTED]> wrote: > why does below fail? > > - where it's failing - > open my $source, "<", "/tmp/server.log" > or die "Could NOT open /var/log/server.log: $!"; > my $file = new IO::Handle; > while ($_ = $fil

Re: trying to use IO::Handle

2008-04-13 Thread Rob Dixon
Richard Lee wrote: > > why does below fail? > > - where it's failing - > open my $source, "<", "/tmp/server.log" > or die "Could NOT open /var/log/server.log: $!"; > my $file = new IO::Handle; > while ($_ = $file->getline($source) ) { > ---

trying to use IO::Handle

2008-04-13 Thread Richard Lee
why does below fail? - where it's failing - open my $source, "<", "/tmp/server.log" or die "Could NOT open /var/log/server.log: $!"; my $file = new IO::Handle; while ($_ = $file->getline($source) ) { Uncaught exception from user cod