|
satest4 posted:$ echo 'END { warn "Dying!\n" } kill("TERM", -$$)' |perl That works, so it looks like we're.. Suffering from buffering
|
# ? Sep 23, 2008 20:42 |
|
|
# ? May 18, 2024 05:23 |
|
Sartak posted:That works, so it looks like we're.. Yeah, so for real fun, you can do this... code:
s139252 fucked around with this message at 21:23 on Sep 23, 2008 |
# ? Sep 23, 2008 21:08 |
|
Is there an equivalent of PHP's 'break' in Perl? What does 'last' do?
|
# ? Sep 25, 2008 05:21 |
|
'last' will exit a while/for/foreach/etc loop, like 'break'. 'continue' is 'next' in perl, though perl does have a continue statement, it just works differently than you'd expect. Finally perl also has a 'redo', which restarts the loop without evaluating the conditional again. perldoc -f (last|first|redo|continue) has all of the details.
|
# ? Sep 25, 2008 06:48 |
|
Ninja Rope posted:'last' will exit a while/for/foreach/etc loop, like 'break'. 'continue' is 'next' in perl, though perl does have a continue statement, it just works differently than you'd expect. Finally perl also has a 'redo', which restarts the loop without evaluating the conditional again. Woah I just looked up continue and I'm not sure if it should be considered a good thing or a language wtf. It's almost like larry wanted something similar to 'catch' but not.. PS genericadmin give me a 1970 regdate and I will love you forever tia
|
# ? Sep 25, 2008 10:09 |
|
I don't see what's wrong with providing hooks into the end of an iteration? Providing it's not abused.
|
# ? Sep 25, 2008 14:46 |
|
Feels kinda hackish, sorta like using goto in C to handle errors. And it looks a little out of place, being tagged onto the end of the loop block. Not very intuitive.
|
# ? Sep 26, 2008 01:55 |
|
TiMBuS posted:Feels kinda hackish, sorta like using goto in C to handle errors. I have to disagree somewhat. I'm a little too set in my C-ish ways to use continue blocks on a regular basis, but it's hard to see it as hackish. It puts the increment code for the loop into its own distinct block thereby increasing semantic content and allowing for reduced duplication of code. It's about as hackish as C's for-loop (which a cynic could call a glorified while loop).
|
# ? Sep 26, 2008 02:57 |
|
Fair enough, I just thought it might be considered a bit tacky. But hey if it's not considered a bad thing, maybe I'll use it. Might be good for handling errors instead of eval/die.
|
# ? Sep 26, 2008 07:50 |
|
Depends on the error. If it doesn't require an exception then using it like a try/catch isn't too . It'd would be a useful place to call rollback(), now I think about it, if you wanted to have one transaction per iteration.
Mario Incandenza fucked around with this message at 10:44 on Sep 26, 2008 |
# ? Sep 26, 2008 10:41 |
|
Yes, I was also thinking about using it like a cleanup mechanism much like finally, except I can optionally skip it using last. Which in a way is kinda cool. Btw you don't need to attach continue to a loop block, it can be used in any (non-sub) block so it could be used as a rollback anywhere.
|
# ? Sep 26, 2008 12:51 |
|
Using ActivePerl 5.10.0 under WinXP, running this:code:
code:
Mithaldu fucked around with this message at 14:24 on Sep 27, 2008 |
# ? Sep 27, 2008 13:28 |
|
It looks like OpenGL probably isn't thread-safe. I'm far from an expert here but I think perl threads avoid sharing resources as much as possible, duplicating them when needed. The error suggests that once OpenGL is initialized you can't clone it because there's an object (GLUquadricObjPtr) missing from OpenGL::Quad's inheritance table.. for some reason. Honestly I got no idea why this would happen. Maybe try adding 'use threads::shared' and it might not clone the object? PS your example works just fine on Strawberry Perl with an OpenGL module I installed with ppm (OpenGL 0.56 from http://www.bribes.org/perl/ppm)
|
# ? Sep 28, 2008 05:34 |
|
Method::Signatures looks promising. It relies on Devel::Declare, which seems to do some semi-evil poo poo that kerplodes the debugger; however it's still pretty cool to write this:code:
|
# ? Sep 28, 2008 06:19 |
Has anyone used CGI-Ajax? I need a way to implement a callback from an Ajax function, but it doesn't look like it supports it. I have an app that queries a remote server for a bunch of service statuses (running|stopped|starting). Using CGI-Ajax, I've implemented a 'refresh' button, which refreshes the service status in an Ajaxy manner (doesn't reload the whole page). This currently works fine. What I want to do, is make my 'refresh' button change into a 'loading' button while the refresh process is running (usually takes anywhere from 1-6 seconds). Then, when the Ajax request has completed, it'd change back into a 'refresh' button. I'm getting feedback from my users that they want/need more visual feedback that the process is running (if no service-statuses have changed, there's no visual feedback that anything at all is happening). I'm going to commit a cardinal sin, and paste my javascript code here, as it is the relevant code. The ajax_refresh_services() function is a Perl function... the first param is the server name and second is the name of the div to paste the output into. code:
What I think needs to happen, is for me to be able to specify a callback in my ajax_refresh_services() function. That way, when the services are refreshed, it'd change my button back to the original loading button. I googled around but it doesn't look like CGI-Ajax supports this. Any ideas?
|
|
# ? Sep 30, 2008 13:21 |
|
TiMBuS posted:It looks like OpenGL probably isn't thread-safe. No idea about strawberry, i use ActivePerl. Anyhow, you're pretty much right. This fixed it: code:
|
# ? Sep 30, 2008 14:19 |
|
syphon^2 posted:CGI::Ajax HTTP is not a stateful protocol, so it can't signal you when some event occurs. One way to do what you want is to change your icon to "loading" and register a timer callback to request the status from your backend every few seconds. If the backend indicates it is finished, you change the icon back to "refresh" and stop the timer. Also, try to think in terms of "requesting a resource" rather than "calling a perl function from javascript". For example, your javascript timer callback might request "http://yoursite.com/foo/status/39293" and get back an XML response. How the backend services the request is private to the backend application... your frontend just knows about some interface it provides at that URI.
|
# ? Sep 30, 2008 14:33 |
Hmm, I guess I was just hoping for someone to come in and say 'oh you could just use the so-and-so method for a call-back'. I have a couple solutions in mind, but I don't like them (involves putting too much HTML into my .pm file). EDIT: Ok, I'll hijack my own post for a completely different question involving HTML::Template and best practice. How would you guys do this? I have a web-app that displays a bunch of junk, and one thing it displays is an overall "Pass|Fail". Stylistically speaking, I want to color this text, green if it's a 'pass', red if it's a 'fail'. HTML::Template doesn't have a lot of function, since it tries to separate code and design (I know template toolkit can do this by matching the variable in the template, but I really like HTML-Template's idea of keeping code out of your HTML). The only way I could think of was computing what color the font should be inside my method, and then passing the template two variables. code:
code:
syphon^2 fucked around with this message at 22:31 on Sep 30, 2008 |
|
# ? Sep 30, 2008 22:15 |
|
CGI::Ajax allows you to specify a javascript callback instead of a div to insert the returned xml(html) into. The how-to is on the perldoc page:perldoc posted:Sending Perl Subroutine Output to a Javascript function So how I would set it up is I'd hook up the refresh button to change itself into a 'loading' image, then send the ajax request, then have the processing function change the image back to a button before changing the contents of the target div. Shouldn't be too hard.
|
# ? Oct 1, 2008 08:55 |
|
And listen to genericadmin/satest4 because he is right. Ajax doesn't just magically call your perl functions, it's the user requesting a specific page using get/post just like an ordinary browser request and this could be causing an undesired performance hit depending on how your web app is set up to handle requests. Just something to look out for. In regards to your other question about Html::Template, you can always use <TMPL_IF>: code:
e: why not make a css class for 'Fail' and 'Pass' and use <span class='<TMPL_VAR COLOR>'> <TMPL_VAR COLOR> </span> ee: OR use Html::Template in your css code and use tmpl_if to set the color in there. That would be far less ugly. TiMBuS fucked around with this message at 09:27 on Oct 1, 2008 |
# ? Oct 1, 2008 09:22 |
|
TiMBuS posted:ee: OR use Html::Template in your css code and use tmpl_if to set the color in there. That would be far less ugly. I think you had it right the second time. Have HTML::Template change the class that the div is a part of, don't have it change the CSS. Ideally your CSS should be specified in a separate file and cached by the client's browser so it doesn't need to be re-sent for each request.
|
# ? Oct 1, 2008 10:21 |
TiMBuS posted:CGI::Ajax allows you to specify a javascript callback instead of a div to insert the returned xml(html) into. The how-to is on the perldoc page: TiMBuS posted:e: why not make a css class for 'Fail' and 'Pass' and use <span class='<TMPL_VAR COLOR>'> <TMPL_VAR COLOR> </span> Thanks so much for your help guys!
|
|
# ? Oct 1, 2008 12:14 |
|
I'm trying to get a script going that'll use the GPC wrapper module to try to join some polygons together. My problem is that I can't get the code that generates the polygons to be in the proper format. It needs to be an AoA, and I can't get the HoAoA that I'm storing the polygons in to spit the data back as a pure array of arrays. I've stripped out all code that doesn't affect my program, and stated the issues in the comments. code:
Roseo fucked around with this message at 21:46 on Oct 2, 2008 |
# ? Oct 2, 2008 21:12 |
|
I'm so lost. I can't tell if you're doing something wrong or saying something wrong. What does Dumper \%locs give you?
|
# ? Oct 2, 2008 21:35 |
|
Oh, hell, I stated that wrong. Editing for clarification. Do you want Dumper(\%polys)? %locs is a HoA with the input coordinates, %polys is a HoAoA with the resultant polygons stored as an AoA inside a hash indexed by the name of the location.
Roseo fucked around with this message at 21:53 on Oct 2, 2008 |
# ? Oct 2, 2008 21:46 |
|
I have no idea what you're asking. You want to emit an AoA, which you're currently doing. And you're also reading a HoAoA, which you're currently doing. What is broken? Edit: Christ. Dereferencing. You have a hash whose key is a locname and whose value is an object, implemented as an AoA, but you want a real array of point objects (implemented by a two element array) for feeding into something else. code:
Triple Tech fucked around with this message at 21:59 on Oct 2, 2008 |
# ? Oct 2, 2008 21:53 |
|
Triple Tech posted:
Time to reread up on dereferencing, I think. Tried enclosing $poly($key) in everything I could think of, except @{}. Thanks.
|
# ? Oct 2, 2008 22:05 |
|
Triple Tech posted:
:/ my @polygons = values %poly;
|
# ? Oct 3, 2008 01:02 |
|
TiMBuS posted:my @polygons = values %poly; I'm sorry I let you guys down.
|
# ? Oct 3, 2008 02:45 |
|
Has anyone had any success with gtk-perl on windows? It's great in linux but in windows it chokes trying to use the gtk source to build, not to mention I have no idea how to make a small gtk runtime distributable. I found a gtk2 ppm repository but it crashes on bad dll dependancies when I try to run it. Maybe I should switch to wxPerl.
|
# ? Oct 4, 2008 09:06 |
|
In ActivePerl PPM, you can add the trouchelle repository (if you're on 5.10.0). Have you tried the GTK module from there? It fails on install when trying to download the libatk 1.0.0 dll, but that should be a trivial matter of hunting down the correct file and putting it in /bin. Edit: Libraries here: http://trouchelle.com/ppm/scripts/dll/ ; Glib, ExtUtils-PkgConfig, Cairo needs installed too, manually. And since GTK is retarded, you'll need to copy C:\Perl\site\lib\auto\Cairo\Cairo.dll to C:\Perl\bin, as well as http://trouchelle.com/ppm/scripts/dll/libpng12-0.dll.gz. The synopsis example worked for me after that. As for making an executable: I did it by making a bin directory in my project directory which contains the perl executable and dlls. Then i added site/lib, open a command shell, sysinternals' procmon and try to run my script with "bin\perl script.pl". Procmon will tell you what files perl is looking for and if you use filters cleverly you can quickly have it weed out the ones it has found after you copied them to "site/lib" and iteratively build up a small distro for your script. Next step would be to make sure that your sript is a module and is in some appropiately named sub-directory. Then you create a .bat file in the main directory that does the above perl call, and convert it with one of the many bat2exe tools into an executable. Lastly, use http://www.perlmonks.org/?node_id=410030 to lose the command shell window. You can see an example of the whole setup in action here: http://code.google.com/p/dwarvis/source/browse/trunk/lifevis Mithaldu fucked around with this message at 15:10 on Oct 4, 2008 |
# ? Oct 4, 2008 14:54 |
|
That's odd. The package from there worked properly this time. Maybe it's because I had another (newer?) gtk distribution installed and they were clashing. Ok well then, if the .dlls are all in the perl dir, they might even work with PAR. Now to get gladeXML working..
|
# ? Oct 4, 2008 16:01 |
|
Just a reminder that Devel::NYTProf is incredible. Tim Bunce gave a very informative Devel::NYTProf talk about what it does, how it does it, and how it's better than the others (which all kinda suck in different ways)
|
# ? Oct 4, 2008 18:17 |
|
Interesting talk. I didn't know Devel::DProf was so useless. Eurgh, so I need to get Crypt::OpenPGP installed on a fresh Etch box but it looks like the module hasn't been touched for nearly 6 years and the test suite is blowing up like a motherfucker. In theory I should be able to drop in Crypt::GPG if I mock the interface, yes? Mario Incandenza fucked around with this message at 08:46 on Oct 7, 2008 |
# ? Oct 7, 2008 08:40 |
|
I wish any of the Profilers would work in multi-thread OpenGL applications. Either they just plain don't work, since GLUT hijacks the exit call or they only pick up the first thread my program starts, which only checks the memory use every two seconds.
|
# ? Oct 7, 2008 17:59 |
|
SpeedFrog posted:Interesting talk. I didn't know Devel::DProf was so useless. Maybe you can get it running, someone left a rating on the module telling you how to make it work: quote:I have used this package for years and only recently have I had any problems. It does what it says on the tin and the documentation and samples make it easy to use but not to install. The main problem is whenever I upgrade Perl these days I get an error which is basically to do with the use of scalars and strict. This can be overcome by installing the Scalar::List::Utils package which you should download and install from source separately and keep so you can re-install it next time you upgrade Perl. The other problem was getting hold of the pari package which disappeared for a while so now I keep a copy of the distribution just in case. I mainly use it for encrypting emails using GnuPG keys without having to enter a password. GnuPG unfortunately lacks a simple interface for this since you can not pipe data in and out and use your keys to encrypt. If you could, it would virtually make all these types of modules redundant since a simple system call would do the job. Now to decide if making an interface or hunting down old modules is easier..
|
# ? Oct 8, 2008 02:03 |
|
It's a shame that Devel::NTYProf doesn't work on Windows. I wonder what it's written on top of that Windows lacks? Edit: I've been asked to do a really informal presentation on Lua to a group of Perl programmers, but I still want to take it seriously. Aside from generic "learn other languages" benefits, what can learning Lua give Perl programmers? - Exposure to Parrot - Exposure to games programming - Uhh.... Triple Tech fucked around with this message at 02:32 on Oct 8, 2008 |
# ? Oct 8, 2008 02:29 |
|
Triple Tech posted:It's a shame that Devel::NTYProf doesn't work on Windows. I wonder what it's written on top of that Windows lacks?
|
# ? Oct 8, 2008 02:41 |
|
I have a commit bit to Devel::NYTProf now, so if anybody wants to help support Windows, feel free to talk to me here or wherever. Triple Tech posted:Edit: I've been asked to do a really informal presentation on Lua to a group of Perl programmers, but I still want to take it seriously. Aside from generic "learn other languages" benefits, what can learning Lua give Perl programmers? Lua is actually very similar to Perl. Both provide high-level, orthogonal features. The biggest difference would be Lua's data structure: the table. They're like a hash and an array. Lua has metatables as well, which are actually very much like Perl's tying mechanism (running custom code when you get, set, etc. values in a variable). The feature is saner, and used a lot more in libraries, in Lua than in Perl. I can't think of any specific things that would help a Perl programmer though. I really like Lua, I just wish it had the CPAN.
|
# ? Oct 8, 2008 03:12 |
|
|
# ? May 18, 2024 05:23 |
|
Maybe I'm being too idealistic (probably) but if I was developing a sort of Perl tool, a meta-program if you will, I would have concentrated on making it work on the language level and not use any OS-level stuff.
|
# ? Oct 8, 2008 03:18 |