RE: Win32 and alarm
If you are using Windows 2000 or later you can use the Job subsystem to set a time limit on the subprocess. Here is a simple job.pl script that executes any command, but only for a specified number of seconds: use Win32::Job; my $job = Win32::Job-new; my $timeout = shift; my $exe = $ARGV[0]; s,,\\,g, ($_ = qq($_)) for @ARGV; $job-spawn($exe, @ARGV); $job-run($timeout); I didn't know Win32::Job! Nice to hear it... Regards, HT ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
readdir problem
Hi all, I am trying to read only files in a directory; I need to jump over the dot files and any subdirectories. Seems like a simple thing, however with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if (/^\./); # skip over dot files print file name is: $file\n; } I get . and .. and all subdirectories. with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if -d $file); # skip over directories print file name is: $file\n; } I skip the dot files but I still get the subdirectories. Any idea how do I get only the plain files? Thanks, Dan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: readdir problem
Hi all, I am trying to read only files in a directory; I need to jump over the dot files and any subdirectories. Seems like a simple thing, however with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if (/^\./); # skip over dot files There's probably a faster way but you can change this to: next if (($file =~ /^\./) || (! -f $file)); ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: readdir problem
At 10:18 AM 11/29/2006, Dan Jablonsky wrote: Hi all, I am trying to read only files in a directory; I need to jump over the dot files and any subdirectories. Seems like a simple thing, however with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if (/^\./); # skip over dot files print file name is: $file\n; } I get . and .. and all subdirectories. with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if -d $file); # skip over directories print file name is: $file\n; } I skip the dot files but I still get the subdirectories. Any idea how do I get only the plain files? Problem with case 1, I think, is that next if (/^\./); compares to $_, not $file. Should be: foreach my $file (readdir(DIR)) { next if ($file =~ /^\./); } Problem with case 2, I think, is that you need to provide a full path name to -d: foreach my $file (readdir(DIR)) { next if (-d $dir\\$file); } Keep in mind that I'm using \ as a separator, which should be / for Unix/Linux. Also, -d $file might work if you know that the current directory is $dir, but it seems safer to me to just give a full path name. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32 and alarm
Another way to do it is to spawn a thread and do the command there and return the pid to the main thread. That way u can monitor the command and get it's output. If it hangs, u can kill it from the other thread. -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: readdir problem
Dan Jablonsky wrote: Hi all, I am trying to read only files in a directory; I need to jump over the dot files and any subdirectories. Seems like a simple thing, however with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if (/^\./); # skip over dot files next if $dir/$file =~ (/^\./); or just do them both with : next if -d $dir/$file; print file name is: $file\n; } I get . and .. and all subdirectories. with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if -d $file); # skip over directories print file name is: $file\n; } I skip the dot files but I still get the subdirectories. Any idea how do I get only the plain files? ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: readdir problem
Recently I like to use File::Slurp for read/write files and also dir. use File::Slurp; my $dir = shift; my @files = grep { ! /^\./ and -f $dir . /$_ } read_dir($dir); print join(\n, @files), \n; Regards, HT -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan Jablonsky Sent: Thursday, November 30, 2006 12:18 AM To: perl-win32-users@listserv.ActiveState.com Subject: readdir problem Hi all, I am trying to read only files in a directory; I need to jump over the dot files and any subdirectories. Seems like a simple thing, however with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if (/^\./); # skip over dot files print file name is: $file\n; } I get . and .. and all subdirectories. with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if -d $file); # skip over directories print file name is: $file\n; } I skip the dot files but I still get the subdirectories. Any idea how do I get only the plain files? Thanks, Dan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: readdir problem
$Bill Luebkert wrote: Dan Jablonsky wrote: Hi all, I am trying to read only files in a directory; I need to jump over the dot files and any subdirectories. Seems like a simple thing, however with opendir(DIR, $dir) || die can't opendir $dir: $!; foreach my $file (readdir DIR) { next if (/^\./); # skip over dot files next if $dir/$file =~ (/^\./); My bad - it should just be $file above and the below is correct. or just do them both with : next if -d $dir/$file; ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Event Sink script
Hello, Sorry to ask again... Anyone has ever wrote a MS Exchange server's Event Sink script in Perl? Today I was requested to make a simple one but I don't like to write in VBScript. Any information is OK. Perl cann't be used for Event Sink? Regards, Hirosi Taguti ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs