Help parsing a large file

2002-08-21 Thread Max Clark

Hi,
 
I am trying to parse a large text file (10 MB, 400K lines) with the
following code. This is running FreeBSD-Stable (dual proc, 1GB ram),
however I keep receiving messages that I am out of memory, or that the
query timed out. I need to parse a file with email addresses to sort
out garbage.
 
How can I do this better?
 
Thanks in advance,
-Max
 
#!/usr/bin/perl -w
 
use Email::Valid;
 
open (GOOD, valid.good) || die $!;
open (BAD, valid.bad) || die $!;
 
while () {
if (Email::Valid-address( -address = $_,
-mxcheck = 1,
-fudge = 1 )) {
print GOOD;
} else {
print BAD;
}
}



Trapping Ctrl C

2002-07-15 Thread Max Clark

Hi.

I'm looking for a way to run an operation (like a while () loop for
example) until the user presses ctrl-c. Except instead of ending the perl
script I want to trap the ctrl-c and present the user a menu of options.

Is this possible?
Thanks, Max

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




tail -f with cgi

2002-07-12 Thread Max Clark

Hi,

I am trying to write a cgi program to tail -f a log file. I have a perl
script that will open and print the log file, however it closes as soon as
it reads whatever is in the file at that particular time. How do I mimic
tail -f functionality?

Thanks,
Max

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: tail -f with cgi

2002-07-12 Thread Max Clark

I found the file::tail module on cpan... 

#!/usr/bin/perl -w

use File::Tail;

my $log = /usr/local/apache2/logs/access_log;

$file=File::Tail-new
(
name=$log,
interval=2,
maxinterval=10
);

while (defined($line=$file-read)) {
print $line;
}

It does exactly what I need. I can't seem to get this to work correctly
through cgi. Any ideas?

Thanks,
Max

-Original Message-
From: Max Clark [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 11, 2002 4:44 PM
To: '[EMAIL PROTECTED]'
Subject: tail -f with cgi


Hi,

I am trying to write a cgi program to tail -f a log file. I have a perl
script that will open and print the log file, however it closes as soon as
it reads whatever is in the file at that particular time. How do I mimic
tail -f functionality?

Thanks,
Max

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Removing ^M (Carriage Return) from files on *nix

2002-04-27 Thread Max Clark

Another way would be like this...

$ col -bx  dosfile  newfile

It's important that you use a different file name for the newfile.

Max

-Original Message-
From: Shaun Fryer [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 26, 2002 5:03 PM
To: Perl Beginners
Subject: Removing ^M (Carriage Return) from files on *nix


Someone mentioned this problem recently. Here's a solution.
Open the file in vi and type...

:g/[Ctrl+v][Ctrl+m]/s///

That will remove all the Carriage Returns from the file in
one shot.

===
 Shaun Fryer
===
 London Webmasters
 http://LWEB.NET
 PH:  519-858-9660
 FX:  519-858-9024
===


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]