[26711] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8809 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 29 11:05:37 2005

Date: Thu, 29 Dec 2005 08:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 29 Dec 2005     Volume: 10 Number: 8809

Today's topics:
    Re: 'file changed'-event <vtatila@mail.student.oulu.fi>
    Re: Addressing the cursor of a VT100 style terminal emu <dickey@saltmine.radix.net>
        external programm execution not possible... <m.mertens@gmx.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 29 Dec 2005 12:48:56 +0200
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: 'file changed'-event
Message-Id: <dp0euu$rce$1@news.oulu.fi>

Anno Siegel wrote:
> Michael Goerz  <news2132@8439.e4ward.com> wrote in comp.lang.perl.misc:
>> I'm trying to execute a sub whenever a certain file on the disk changes.
>> Currently, I'm doing this with an infinite loop <snip>
>> Can I implement this with an event-based approach
> Unless your file system supports events you'll ultimately have to watch
> the file.

Michael,
You didn't mention your operating system in the post. If you happen to be 
running Windows, might the Win32::ChangeNotify module be of help? It can be 
found at:

http://search.cpan.org/~gsar/libwin32-0.191/ChangeNotify/ChangeNotify.pm

It is also available via ppm using the Active State repositories. Ano's 
comment about having to poll manually unless the OS supports events got me 
curious. Is the Win32 API function used by this module merely some syntactic 
sugar to abstract away ugly polling code? Or alternatively, does the file 
system support a true publish-subscribe model, that is events?

> file system's resolution is one second, so you should only stat the file
> once a second.  If you don't need maximum resolution make the intervals as
> long as reasonable.
Well said. I mean, I've used similar polling tacs for the clipboard before 
as the WaitForChange method has never worked for me properly. Sleeping at 
least a second is of great help in terms of performance and llengthning the 
interval is a compromise between responsivness and CPU or file system usage 
as you pointed out. I guess this applies broadly to a large variety of 
poling.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/ 




------------------------------

Date: Thu, 29 Dec 2005 13:10:16 -0000
From: Thomas Dickey <dickey@saltmine.radix.net>
Subject: Re: Addressing the cursor of a VT100 style terminal emulator using perl
Message-Id: <11r7o1o6nktfl54@corp.supernews.com>

Samwyse <samwyse@gmail.com> wrote:
>> don't see where that queries the current terminal size.  Ditto for 
>> Term::ANSIColor.

> Actually, when a terminal is resized, your app gets a SIGWINCH signal. 
> You should then issue an ioctl to get the new size:
> 	struct winsize size;
> 	ioctl(fileno(stdout), TIOCGWINSZ, &size);
> This way, you don't have to query the terminal and worry about the user 
> hitting a key at the wrong time.  The ncurses library handles all of 
> this for you, I suppose that Term::Cap does as well.  The next time you 

I don't belive Term::Cap does this since it doesn't have a getch() method.
(likewise Term::AnsiColor).

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net


------------------------------

Date: Thu, 29 Dec 2005 11:15:18 +0100
From: Michael <m.mertens@gmx.net>
Subject: external programm execution not possible...
Message-Id: <43b3b736$0$26901$9b4e6d93@newsread4.arcor-online.net>

Hi,
   my application reads several paths from a configruation file.
   Some of these paths pointing to an executable which are to start
   with an input file. Example: Adobe Reader with a pdf-file.

   The executables are stored in c:\Program Files\...

   When I try to execute the following, Perl is obvioulsy not able
   to handle the spaces within the path information correctly and
aborts with
'c:/Programm' is not recognized as an internal or external command, 
operable program or batch file

    Does anyone know a solution or could help me?


perl-code:

use Config::Simple;

Initiale('cfgfile.ini');

################################################
sub Initialize {
################################################
     my $cfgfile = shift;
     my $cfg;

     $cfg = new Config::Simple($cfgfile) or Error(20,[$cfg->error]);

     # read path section

     $p2adobe = $cfg->param("path.adobe");
     $p2pdf = $cfg->param("path.pdf");


     exec( $p2adobe.' '.$p2pdf.'test.pdf' );

} # Initialize



cfgfile.ini:


[path]
adobe 	= 'c:/Program Files/Adobe/Acrobat 7.0/Reader/AcroRd32.exe';
pdf 	= 'e:/PDF/';


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8809
***************************************


home help back first fref pref prev next nref lref last post