Re: running a perl app
It's the cygwin/unix command. It tells u which object in ur path will be exectued. D:\autocratwhich perl /c/perl/bin/perl -- 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: running a perl app
- Original Message - From: Jerry Kassebaum [EMAIL PROTECTED] To: [EMAIL PROTECTED]; perl-win32-users@listserv.ActiveState.com Sent: Wednesday, April 19, 2006 1:09 PM Subject: Re: running a perl app To determine the correct path for your perl interpretor, use: which perl -- Please give me a context. Note that the original post pertained to a Unix-like system (not Windows) - and the answer you've quoted above pertains primarily to Unix-like systems. On Unix -like systems if you were to enter 'which perl' at the command line, then the fully qualified path to the perl executable would be returned. On windows the same command could successfully be run in the msys shell, or in Cygwin's bash shell - and perhaps some other shells, too - but not the cmd.exe shell, unless you've installed a which.exe such as that available from http://gnuwin32.sourceforge.net/packages.html (as I have done): E:\downloadswhich perl D:/perl58_M/5.8.8/bin/perl.EXE Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Opening an Excel workbook with links to other data sources
---8 When I manually open an Excel file, it bring up a dialog box stating that the workbook contains links to other data sources and asking if the data should be updated. ---8 Try and see if you can supress the pop up with this:- $Excel-{DisplayAlerts} = 0; If not you may have to fudge something with Win32::GuiTest Just in ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Please remove me from maling list
Please remove me from maling list Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1/min.___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: running a perl app
Title: RE: running a perl app To determine the correct path for your perl interpretor, use: which perl -- Please give me a context. Note that the original post pertained to a Unix-like system (not Windows) - and the answer you've quoted above pertains primarily to Unix-like systems. On Unix -like systems if you were to enter 'which perl' at the command line, then the fully qualified path to the perl executable would be returned. On windows the same command could successfully be run in the msys shell, or in Cygwin's bash shell - and perhaps some other shells, too - but not the cmd.exe shell, unless you've installed a which.exe such as that available from http://gnuwin32.sourceforge.net/packages.html (as I have done): Here's a perl version of 'which'. But it looks not only in $ENV{PATH} but also in @INC directories. I also created a which.bat file which calls which.pl because I am THAT lazy ;-) ### use Cwd; @_ = @ARGV; my $cwd = getcwd unless $cwd = $ENV{'PWD'}; my $inc = join(;, @INC); $ENV{'PATH'} = $ENV{'PATH'};$inc; $regexp = shift || die usage: $0 regexp\n; for $dir (split(/;/,$ENV{'PATH'})) { if ($dir =~ /^.*[\\\/]$/) { chop($dir); } if ($dir =~ /\//) { $delim = \/; } else { $delim = \\; } opendir(DOT, $dir) || cantdo($!); while ($_ = readdir(DOT)) { print ${dir}${delim}$_\n if ($_ =~ /$regexp/i); } close(DOT); } sub cantdo { my $error = shift; warn can't opendir : $error\n; next; } ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: exhausting file handles in Win32
Indeed! This seems to get the job done and it provides an excellent spring board for diving into the Win32API module. Thanks Billy! lol. Now, I'll be reading perldocs and the like instead of testing software ;) Kindest regards, Carlos Billy Conn wrote: I'd try the following: #!/usr/bin/perl -w use strict; use File::Spec; use POSIX qw(tmpnam); use Win32API::File; my $num = shift || 10; my (@tempfiles, @temphandles); #impatience $| = 1; END { map {CloseHandle $_ } @temphandles; #hubris map {unlink $_ } @tempfiles; }; my $temp_dir = File::Spec-tmpdir(); while($num--) { #laziness my $path = File::Spec-rel2abs(File::Spec-catfile($temp_dir, tmpnam() )); my $hObject= Win32API::File::createFile( $path, 'qrwtc' ); push @temphandles, $hObject; push @tempfiles, $path; print object: $hObject :, $^E, \n; } sleep(60); I was able to open 100,000 filehandles with no problem, though that unlink kinda acts weird. DeleteFile might work, but I figured this was enough to start you in the right direction. cabz wrote: Hello! -- Gilbert Ryle: Can I help you? Student : Perhaps. I'm looking for 'The Forest', but all I see are these damned trees! ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Error: No valid repositories: Error: 500 Can't connect
Dear friends, when I try to use ppm I get the following error message Error: No valid repositories: Error: 500 Can't connect to ppm.ActiveState.com:80 (Bad protocol 'tcp') Error: 500 Can't connect to ppm.ActiveState.com:80 (Bad protocol 'tcp') I'm running Windows XP with no proxy, but I guess it can be the firewall that is acting up? I saw in the archives that someone suggested uninstalling and reinstalling the tcp/ip protocaol, but it seems that can't be done on XP. What shall I do? Is there a workaround? TIA /BP 8^) -- Benct Philip Jonsson -- melroch at melroch dot se Maybe is a strange word. When mum or dad says it it means yes, but when my big brothers say it it means no! (Philip Jonsson jr, age 7) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: running a perl app
At 04:32 PM 4/19/2006 +1000, Sisyphus wrote: On windows the same command could successfully be run in the msys shell, or in Cygwin's bash shell - and perhaps some other shells, too - but not the cmd.exe shell, unless you've installed a which.exe such as that available from http://gnuwin32.sourceforge.net/packages.html (as I have done): E:\downloadswhich perl D:/perl58_M/5.8.8/bin/perl.EXE Actually the Cygwin commands are independent exe's and don't have to be run from any certain shell. I run cygwin commands from cmd.exe all the time. The key difference is that they act and return output in the context of the cygwin system. But it's not too hard to flip /c/perl/bin/perl into c:\perl\bin\perl in ur mind. But for the most part they act just like any other shell app. -- 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: Opening an Excel workbook with links to other data sources
Hello, Issue: opening an excel file brings up a dialog box stating that the workbook contains links to other data sources and asks if the data should be updated. Just-in's suggestion of adding $Excel-{DisplayAlerts} = 0; to modify the code to be: use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE-GetActiveObject('Excel.Application') || Win32::OLE-new('Excel.Application', 'Quit'); $Excel-{DisplayAlerts} = 0; my $Book = $Excel-Workbooks-Open($file); # open Excel file my $Sheet = $Book-Worksheets(1); # select worksheet number 1 $Book-Close; did not enable the perl code to prevent Excel from bring up that dialog box. Just-in's other suggestion was If not you may have to fudge something with Win32::GuiTest, but didn't elaborate on the something ... So one thought is to have two threads -- one thread is as above; the other thread periodically searches for appearence of the Excel dialog box, and when it finds one, uses SendKeys to get rid of the box. Before I actually try the above scheme, any critique on it? or any other suggestions? Thanks, --Suresh ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
waking up a sleeping thread
HiIf I have a thread that is sleeping indefinitely, how can I wake it from some other thread?use strict;use warnings;use Thread qw(async);my $thr = async { print thread is sleeping\n; sleep; print thread is back\n;};sleep(1);## do something here to wake the thread up ... but what?$thr-join;print DONE;thanks Daniel-- Daniel McBreartyemail : danielmcbrearty at gmail.comwww.engoi.com : the multi - language vocab trainerBTW : 0873928131 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Iffor
Thanks, Just ordered it from Amazon. Went the super-cheap route and ordered it free shipping ... should have it in a week or so. If anyone cares, I ended up using this asmy code ... it accomplished exactly what I was looking for: --- for (grep($_ !~ /$zipDir/i, @folders)) --- For those who weren't fond of that .. I'm sorry, but I did comment the hell out of that line =) Bill Ng From: D D Allen [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 18, 2006 8:55 PMTo: Ng, BillCc: perl-win32-users@listserv.ActiveState.comSubject: Re: Iffor snip good advice Read Damian Conway's Perl Best Practices. And when you feel the need to write clever code, read it again./snip ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: waking up a sleeping thread
## do something here to wake the thread up ... but what? You can try: $thr-freshCoffee(); and if that doesn't work, you can try: $thr-inviteMyKidsOverOnASaturdayMorning(); The latter always seems to work for me. :) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Screen Scraping a DOS window
Does anyone know of a good way to screen-scrape a DOS window from Perl? We have error messages that get reported in various and sundry ways, but thought it might be a nice addition to scrape the last 5-25 lines from the DOS box just as a good measure. Thanks in advance for any suggestions... Howard Maher [EMAIL PROTECTED] ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Iffor
Bill Ng [bill.ng AT citigroup.com] wrote: Thanks, Just ordered it from Amazon. Went the super-cheap route and ordered it free shipping ... should have it in a week or so. If anyone cares, I ended up using this as my code ... it accomplished exactly what I was looking for: --- for (grep($_ !~ /$zipDir/i, @folders)) --- For those who weren't fond of that .. I'm sorry, but I did comment the hell out of that line =) Bill Ng D D Allen [dewey.allen AT us.ibm.com] snip good advice Read Damian Conway's Perl Best Practices. And when you feel the need to write clever code, read it again. /snip Bill, as long as your goal was *less efficient and obfuscated code*, then you succeeded. You do realize that you are making a second copy of all of the contents of @folders less the items that do not match your regex? In the general case, if @folders is very large, this is hugely expensive in terms of memory compared to iterating across the list and just not doing whatever action if the regex does not match. In both cases you are doing the test against each element. As far as obfuscation, yes I read that you commented the hell out of it, but that is little comfort for doing something so obscure and needless. Not only is it harder to maintain, I would suggest that it is harder to extend. And my pity if this code is handed to someone else to maintain. In a subsequent post, D D Allen wrote: Save cleverness for the times when it could make a significant, measurable difference. Sing it, brother! -- Mike Arms ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Screen Scraping a DOS window
If you're referring to the same console that you ran your script from then you can get it all just by redirecting STDOUT and STDERR. It will go back after your script finishes running. open(STDERR,,error.log) or die(Couldn't open 'error.log' for append!\n); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Howard Maher Sent: Wednesday, April 19, 2006 1:44 PM To: perl-win32-users@listserv.ActiveState.com Subject: Screen Scraping a DOS window Does anyone know of a good way to screen-scrape a DOS window from Perl? We have error messages that get reported in various and sundry ways, but thought it might be a nice addition to scrape the last 5-25 lines from the DOS box just as a good measure. Thanks in advance for any suggestions... Howard Maher [EMAIL PROTECTED] ___ 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: running a perl app
- Original Message - From: Chris Wagner . . Actually the Cygwin commands are independent exe's and don't have to be run from any certain shell. I run cygwin commands from cmd.exe all the time. The key difference is that they act and return output in the context of the cygwin system. But it's not too hard to flip /c/perl/bin/perl into c:\perl\bin\perl in ur mind. But for the most part they act just like any other shell app. Interesting - I don't have Cygwin, but I do have an msys shell (which is, roughly speaking, a derivative of Cygwin's shell). It has a 'which' command, but that works only in the msys shell. If I execute it from a cmd.exe shell it just hangs and renders the cmd shell unresponsive. There are, of course, other msys commands that are independent exe's - and they can be run from any shell. Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Iffor
@folders will have, at most 7 objects in it. All strings of less than 80 bytes. Bill Ng -Original Message- From: Arms, Mike [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 19, 2006 5:24 PM To: perl-win32-users@listserv.ActiveState.com Cc: Ng, Bill Subject: RE: Iffor Bill, as long as your goal was *less efficient and obfuscated code*, then you succeeded. You do realize that you are making a second copy of all of the contents of @folders less the items that do not match your regex? In the general case, if @folders is very large, this is hugely expensive in terms of memory compared to iterating across the list and just not doing whatever action if the regex does not match. In both cases you are doing the test against each element. As far as obfuscation, yes I read that you commented the hell out of it, but that is little comfort for doing something so obscure and needless. Not only is it harder to maintain, I would suggest that it is harder to extend. And my pity if this code is handed to someone else to maintain. -- Mike Arms ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
waking up a sleeping thread
hmmm ... tried that, duzzen work ... (scratches head ;). the perldoc for sleep talks about sending a SIGALRM signal, but my poking around revealed no such sig under win XP. I don't know what signal I could send, nor how to send it. I want to wake it, not kill it ...-- Daniel McBreartyemail : danielmcbrearty at gmail.comwww.engoi.com : the multi - language vocab trainerBTW : 0873928131 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: waking up a sleeping thread
sorry for double post ... thought I had only replied to Peter the first time. On 4/20/06, Daniel McBrearty [EMAIL PROTECTED] wrote: hmmm ... tried that, duzzen work ... (scratches head ;). the perldoc for sleep talks about sending a SIGALRM signal, but my poking around revealed no such sig under win XP. I don't know what signal I could send, nor how to send it. I want to wake it, not kill it ...-- Daniel McBreartyemail : danielmcbrearty at gmail.comwww.engoi.com : the multi - language vocab trainerBTW : 0873928131 -- Daniel McBreartyemail : danielmcbrearty at gmail.comwww.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Opening an Excel workbook with links to other data sources
---8--- Just-in's other suggestion was If not you may have to fudge something with Win32::GuiTest, but didn't elaborate on the something ... ---8--- Going down the GuiTest path is forcing things in a less than elegant way. Why not have a dig around in the Object browser (available when you hit Alt-F11 after you launch Excel) - you may have to hit Tools - References and check the Excel box to get the Excel references. You may find a property or method that allows you to override the pop up in question. It's going to take some searching but it may be well worth the effort. Just in ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Opening an Excel workbook with links to other data sources
Check Tools--Options--Calculation Tab and try changing the Calculation radio button to Manual. That might get rid of the message. You just have to keep in mind that you need to manually recalculate your values if you want to see the current data. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Allegakoen, Justin Devanandan Sent: Wednesday, April 19, 2006 3:59 PM To: perl-win32-users@listserv.ActiveState.com Subject: RE: Opening an Excel workbook with links to other data sources ---8--- Just-in's other suggestion was If not you may have to fudge something with Win32::GuiTest, but didn't elaborate on the something ... ---8--- Going down the GuiTest path is forcing things in a less than elegant way. Why not have a dig around in the Object browser (available when you hit Alt-F11 after you launch Excel) - you may have to hit Tools - References and check the Excel box to get the Excel references. You may find a property or method that allows you to override the pop up in question. It's going to take some searching but it may be well worth the effort. Just in ___ 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: Iffor
- Original Message - From: Glenn Linderman . . I think that the for( grep ($_ != 3, @a)) is quite clear in bundling the element selection together, and separating it from the functions being performed. I would much rather see (as suggested earlier on in this thread): for(@a) { next if $_ == 3; For me it is both clearer and more efficient ... but each to his own. On the subject of replacing brackets with modifiers (which I think was also raised earlier on), I was surprised to find that using a modifier is about 25% faster than brackets: ### try.pl ### use warnings; no warnings once; use Benchmark; @x = (1 .. 100); @y = (1 .. 100); $z1 = 0; $z2 = 0; timethese(1, { 'modifier' = 'for(@x) {$z1++ if $_ != 3}', 'brackets' = 'for(@y) {if($_ != 3){$z2++}}', }); print \n, $z1, , $z2, \n; __END__ D:\pscrptperl try.pl Benchmark: timing 1 iterations of brackets, modifier... brackets: 1 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 0.97/s (n=1) (warning: too few iterations for a reliable count) modifier: 1 wallclock secs ( 0.70 usr + 0.00 sys = 0.70 CPU) @ 1.43/s (n=1) (warning: too few iterations for a reliable count) 99 99 Maybe I've misinterpreted the results ?? Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Opening an Excel workbook with links to other data sources
Lynn. Rickards Sent: Wednesday, April 19, 2006 6:02 PM Suresh Govindachar wrote: Hello, Issue: opening an excel file brings up a dialog box stating that the workbook contains links to other data sources and asks if the data should be updated. [...] use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE-GetActiveObject('Excel.Application') || Win32::OLE-new('Excel.Application', 'Quit'); [...] my $Book = $Excel-Workbooks-Open($file); # open Excel file my $Sheet = $Book-Worksheets(1); # select worksheet number 1 $Book-Close; [...] my $Book = $Excel-Workbooks-Open($file, {'UpdateLinks' = 3}); The value 3 I got from some VB code someplace I forget, and have no clue what it means - hunted on MSDN to no avail. Anyone? From the documentation for the open method: ---8--- Opens a workbook. expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad) expressionRequired. An expression that returns the Workbooks object. FileName Required String. The file name of the workbook to be opened. UpdateLinks Optional Variant. Specifies the way links in the file are updated. If this argument is omitted, the user is prompted to specify how links will be updated. Otherwise, this argument is one of the values listed in the following table. Value | Meaning --+--- 0 | Doesn't update any references 1 | Updates external references but not remote references 2 | Updates remote references but not external references 3 | Updates both remote and external references If Microsoft Excel is opening a file in the WKS, WK1, or WK3 format and the UpdateLinks argument is 2, Microsoft Excel generates charts from the graphs attached to the file. If the argument is 0, no charts are created. ---8--- BTW Options to book-Open are fully listed in the Object Browser. --Suresh ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Iffor
- Original Message - From: Glenn Linderman . . Get a load of this variation: perl use warnings; no warnings once; use Benchmark; @x = (1 .. 100); @y = (1 .. 100); @z = (1 .. 100); @w = (1 .. 100); $z1 = 0; $z2 = 0; $z3 = 0; $z4 = 0; timethese(10, { 'forgrep' = 'for(grep($_ != 3, @w)){ $z4++ }', 'next' = 'for(@z) {next if $_ == 3; $z3++}', 'brackets' = 'for(@y) {if($_ != 3){$z2++}}', 'modifier' = 'for(@x) {$z1++ if $_ != 3}', }); print \n, $z1, , $z2, , $z3, , $z4, \n; __END__ Benchmark: timing 10 iterations of brackets, forgrep, modifier, next... brackets: 4 wallclock secs ( 3.73 usr + 0.00 sys = 3.73 CPU) @ 2.68/s (n=10) forgrep: 3 wallclock secs ( 3.19 usr + 0.00 sys = 3.19 CPU) @ 3.14/s (n=10) modifier: 3 wallclock secs ( 2.61 usr + 0.00 sys = 2.61 CPU) @ 3.83/s (n=10) next: 3 wallclock secs ( 2.64 usr + 0.00 sys = 2.64 CPU) @ 3.79/s (n=10) 990 990 990 990 Yeah beats me how 'forgrep' could be faster than 'brackets'. I had also done some timings on use of 'next' and found it to be inexplicably fast. IIRC, there is very little difference (timewise) between next if $_ == 3; and if($_ == 3) {next}. At one stage I got the impression that $_==3 could be evaluated more quickly than $_!=3, but I don't know if that's so. Anyway . I probably wouldn't understand it even if it was explained to me :-) Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: waking up a sleeping thread
At 05:42 PM 4/19/2006 +0200, Daniel McBrearty wrote: If I have a thread that is sleeping indefinitely, how can I wake it from some other thread? First of all u should be use'ing threads, not Thread. Thread is obsolete. To get another thread to wake up u first have to put it to sleep somehow. Then u wake it by sending it a message of some kind. There are several ways to do that. U can use a shared variable, a semaphore, or a message queue. The advantage of the semaphore is that it can perform the function of putting it to sleep and waking it. Read the perlthrtut in the Active State user guide. use threads; use Thread::Semaphore; $semaphore = new Thread::Semaphore(0); # is zero $t1 = threads-create(sub1); print waiting 5...\n and sleep 5; # now that $semaphore is 1, the down can unblock $semaphore-up; sub sub1 { # thread blocks until $semaphore can be non negative $semaphore-down; print doing something; $semaphore-up; } -- 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: Iffor
At 10:42 AM 4/20/2006 +1000, Sisyphus wrote: On the subject of replacing brackets with modifiers (which I think was also raised earlier on), I was surprised to find that using a modifier is about 25% faster than brackets: 'modifier' = 'for(@x) {$z1++ if $_ != 3}', 'brackets' = 'for(@y) {if($_ != 3){$z2++}}', That is actually pretty well known. The reason is that the former is a short circuit style operation. The code has a simple bifurcation. In the latter it is a code block which has to be setup for all the potential things u can put in a code block. Like my's, labels, etc. Simply entering a curly bracket costs money. That's why it's best to avoid them unless ur stringing just way too many and's and or's together. -- 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