|
SA Support Robot posted:Does anyone here use AnyEvent? I am madly in love with it and wish to project my love upon others. That's pretty cool. For curiosity's sake, what has been your greatest use for it so far?
|
# ? Jul 23, 2009 18:34 |
|
|
# ? May 21, 2024 15:24 |
|
The IRC bot talk a few posts back reminded me to upload this IRC HTML formatting module I have been sitting on. So if you every need to export raw IRC to HTML give it a try! http://search.cpan.org/~leedo/IRC-Formatting-HTML-0.01/
|
# ? Jul 23, 2009 19:04 |
|
AnyEvent is pretty great. I'm using it as part of AnyEvent::XMPP. I love that I don't have to deal with POE.
|
# ? Jul 23, 2009 20:08 |
|
SA Support Robot posted:Does anyone here use AnyEvent? I am madly in love with it and wish to project my love upon others. If you wish to project your love onto others then you should talk about actual, real practical applications. Personally i wouldn't have a clue about what it's useful for.
|
# ? Jul 23, 2009 20:12 |
|
Fenderbender posted:That's pretty cool. For curiosity's sake, what has been your greatest use for it so far? Probably the most extensive use of it is for the forums' new search engine. There's an app called "indexmaster" that runs on each of the search servers. It gets information from the forums about what indexes need to be maintained and forks a worker for each one. The master decides when action is needed for a particular index, and sends tasks to the workers over a unix socket. The workers do database work, run indexing jobs, etc, and send progress updates back to the master. The master process also has a tcp-based management interface that can be used to request index status information, check the search daemon status, kick off index jobs manually, alter the running configuration, etc. For example I can telnet in and tell a search server to put GBS into its own index. Sartak posted:AnyEvent is pretty great. I'm using it as part of AnyEvent::XMPP. I love that I don't have to deal with POE. I also moved to it from POE... never did love the POE API. I had ended up using Danga::Socket for a lot of things, but ever since Brad Fitzpatrick went to Google, I've moved away from a lot of his stuff.
|
# ? Jul 23, 2009 20:38 |
|
Use Devel::NYTProf for gently caress's sake. It's amazing and is the only Perl profiler that doesn't suck. Watch Tim Bunce's NYTProf talk from the other day at OSCON.
|
# ? Jul 24, 2009 18:36 |
|
Sartak posted:Use Devel::NYTProf for gently caress's sake. It's amazing and is the only Perl profiler that doesn't suck. Sartak posted:Watch Tim Bunce's NYTProf talk from the other day at OSCON. Edit: Holy crap, NYTProf 3 sounds sexy. Mithaldu fucked around with this message at 19:08 on Jul 24, 2009 |
# ? Jul 24, 2009 19:05 |
|
The new treemap looks really useful.
|
# ? Jul 24, 2009 19:20 |
|
Ok, so here is a potentially stupid Moose question. I have a class that has a "config" property, and a "server" property. The creation of the server property requires that the config property be set so that I can use some of the config fields when setting up the server. Normally I would just set the server property to lazy like so: code:
Do I need to move this into a BUILD sub? Or is there some way to specify the order that properties are defined? edit: I got this working by setting the server in a trigger on config. Still not sure if that is the best approach, though. leedo fucked around with this message at 23:21 on Jul 30, 2009 |
# ? Jul 30, 2009 23:11 |
|
leedo posted:The problem here is that I need server to be built at initialization, not lazily. But, if I set server to not be lazy config is not defined yet. I'd just add the following to your code: code:
leedo posted:I tried using a builder but it still seems to fire off before config is defined. builder and default are really the same thing. Seriously, the only difference is builder takes a method name, and default takes a code reference. leedo posted:edit: I got this working by setting the server in a trigger on config. That seems okay too.
|
# ? Jul 30, 2009 23:43 |
|
This just came up in IRC, guess what this prints:code:
edited for clarity Filburt Shellbach fucked around with this message at 00:23 on Jul 31, 2009 |
# ? Jul 31, 2009 00:08 |
|
I'm not entirely clear on the internals, but it makes sense to me and follows the manual.perldoc posted:Given an expression that specifies a hash element or array element, returns true if the specified element in the hash or array has ever been initialized, even if the corresponding value is undefined. An array is basically a list of addresses pointing at memory entries that carry the values of the array contents. As such an index can either have no address at all (not exists) or the adress to a memory location which carries the value for undefined (exists). Mithaldu fucked around with this message at 00:26 on Jul 31, 2009 |
# ? Jul 31, 2009 00:23 |
|
Didn't know until now that exists and delete could be used on things not hashes. They were always hash methods to me.
|
# ? Jul 31, 2009 00:28 |
|
Mithaldu posted:an index can either have no address at all (not exists) or the adress to a memory location which carries the value for undefined (exists). That's right. It's the same way hashes work with exists versus defined.
|
# ? Jul 31, 2009 00:29 |
|
^^^^ Thanks. Triple Tech posted:Didn't know until now that exists and delete could be used on things not hashes. They were always hash methods to me. When would i want to use exists specifically versus undefined? I understand the difference in what it does, but not the practical use.
|
# ? Jul 31, 2009 01:01 |
|
Mithaldu posted:^^^^ defined will autovivify the hash element, where as exists will not. At least that is how I always understood it.
|
# ? Jul 31, 2009 02:06 |
|
No, autovivification happens when you access a deep structure. return $a{b}{c}; That autovivifies $a{b} to be a hashref, even if %a was empty. You care about defined versus exists when undef is a valid value. For example, when your attribute can contain any Perl value (including undef) and you need to know when the attribute has a value or not, then you use exists.
|
# ? Jul 31, 2009 02:08 |
|
Sartak posted:No, autovivification happens when you access a deep structure. Wow, I could have sworn defined would create the hash key. But yeah I just did a little test and you're definitely right.
|
# ? Jul 31, 2009 02:41 |
|
FYI if anybody still hasn't heard, Perlmonks was hacked along with Mitnick and Kaminsky, admin/saint passwords from September 2008 were leaked but it's likely all accounts were affected.
|
# ? Jul 31, 2009 08:19 |
|
Wow, nerds, way to be.
|
# ? Jul 31, 2009 14:26 |
|
Sartak posted:This just came up in IRC, guess what this prints: That seems to behave as expected. What am I missing? Mithaldu posted:An array is basically a list of addresses pointing at memory entries that carry the values of the array contents. As such an index can either have no address at all (not exists) or the adress to a memory location which carries the value for undefined (exists). Right. An array is a list of pointers to scalars. A scalar is kinda like an object, and there are several types of scalars (IV for integer values, PV for pointers [ie, strings], RV for references to other scalars, etc). Perl also creates a few special static shared scalars... &PL_sv_undef for representing undefined values, plus &PL_sv_yes and &PL_sv_no for storing the result of boolean evaluation. Perl saves memory this way. An array is not a scalar. A hash is not a scalar. This is why you need a scalar reference (an RV) to pass around an array or hash. It also allows Perl to detect "list context" and do other weird Perl things. code:
|
# ? Aug 1, 2009 16:19 |
|
satest3 posted:That seems to behave as expected. What am I missing? You're not missing anything, you just expected it to work the way it actually does. I was certainly surprised when I learned that exists on a middle element of an array could be useful.
|
# ? Aug 1, 2009 16:25 |
|
I don't have an interpreter handy, but I expect: undefined exists defined exists Am I right? baquerd fucked around with this message at 16:32 on Aug 1, 2009 |
# ? Aug 1, 2009 16:30 |
|
quadreb posted:I don't have an interpreter handy, but I expect: No. http://codepad.org http://codepad.org/Q8YbMVce even
|
# ? Aug 1, 2009 16:30 |
|
Otto Skorzeny posted:No. http://codepad.org Yeah, just read the doc, I thought delete would remove the element and shift the array. Ah well, never use it anyway.
|
# ? Aug 1, 2009 16:32 |
|
atomicstack posted:FYI if anybody still hasn't heard, Perlmonks was hacked along with Mitnick and Kaminsky, admin/saint passwords from September 2008 were leaked but it's likely all accounts were affected. The stunning thing is that they stored passwords in plaintext in their database.
|
# ? Aug 3, 2009 22:28 |
|
Still lolin @ '>=6chars' btw
|
# ? Aug 3, 2009 23:31 |
|
CanSpice posted:I'm writing a blog post outlining the steps I took to create my vessel in hopes that it helps other people. Blammo. It's a lot of but hopefully it helps someone out.
|
# ? Aug 4, 2009 03:53 |
|
CanSpice posted:Blammo. Cool! I've forwarded it on to sunnavy. It looks irritating to have to run the builder twice on test fail, I wonder if printing the last 15 lines of the output would be enough. Thanks for filing those bugs. Robustness owns. edit: sunnavy said that without --verbose, all the commands' output goes to build.log. Good enough for me. Filburt Shellbach fucked around with this message at 04:16 on Aug 4, 2009 |
# ? Aug 4, 2009 04:07 |
|
Sartak posted:Cool! I've forwarded it on to sunnavy. Yeah, I didn't know about that build.log file when I was doing this. I've added a footnote about that, prompted by sunnavy's comment on my post. Thanks for forwarding that on to him! General question for the thread: is there a decent module out there for finding out how much memory a computer has? I have a Perl program that calls another app that writes out files, and I can limit those output files by size, and I want to do that by looking at how much memory the computer has. This code needs to run on at least 32- and 64-bit Linux and, if possible, some flavour of recent Solaris as well as OS X.
|
# ? Aug 4, 2009 22:08 |
|
CanSpice posted:General question for the thread: is there a decent module out there for finding out how much memory a computer has? I have a Perl program that calls another app that writes out files, and I can limit those output files by size, and I want to do that by looking at how much memory the computer has. This code needs to run on at least 32- and 64-bit Linux and, if possible, some flavour of recent Solaris as well as OS X. Sys::MemInfo looks like it's simple and builds on basically everything
|
# ? Aug 4, 2009 22:18 |
|
Otto Skorzeny posted:Sys::MemInfo looks like it's simple and builds on basically everything That looks perfect, thanks.
|
# ? Aug 4, 2009 22:27 |
|
I'm a little shaky about how perl deal with namespaces and returning variables. Say I have a subroutine that generates a hash, with at least one hash inside the hash that I'm ultimately trying to generate, like so:code:
|
# ? Aug 10, 2009 21:32 |
|
Man that code hurts so much... I hope someone else fields this. %test is a hash defined by the list returned by make_hashes(). So, I think at face value, your code does what you want. Just know that it's poorly written, stylistically, and is poor Perl.
|
# ? Aug 10, 2009 21:58 |
|
Triple Tech posted:Man that code hurts so much... I hope someone else fields this. %test is a hash defined by the list returned by make_hashes(). So, I think at face value, your code does what you want. Why's that, and how do I fix it?
|
# ? Aug 10, 2009 21:59 |
|
Why I'm glad you asked! It's because it doesn't look like this.code:
Also it's now really clear, by restyling the code, that your %daddy_hash has an uneven number of elements in its assignment. If you wanted nested hashes, that's an entirely different beast.
|
# ? Aug 10, 2009 22:08 |
|
Captain Frigate posted:
What you want here is to use \%little_hash instead of just %little_hash. With the slash there, $daddy_hash{little_hash} will contain a hash reference to %little_hash. Without the \, the contents of %little_hash get flattened into the list being used to define %daddy_hash, which throws things off since you've effectively doing this: code:
I think Triple Tech tried to point this out with his "oh snap" comment, but I'm not sure he fully understood the degree of your misunderstanding. Or maybe I've misunderstood. Also, if you use the \ notion, you need to be aware that a reference to %little_hash points to the same memory that %little_hash uses -- it's not a copy. So if you do '$little_hash{blahblah} = 7' after creating %daddy_hash, it'll still modify the contents of the hash in $daddy_hash{little_hash}. Of course once your function exits, there won't be a reference to %little_hash anymore, so you no longer have to worry about it being modified via things not directly accessing the contents of %daddy_hash (unless you pass the reference somewhere else). Finally, Data::Dumper is your friend for testing various data structures. Just throw "use Data::Dumper;" at the beginning of your program and then stick "print Dumper(\%test);" at the end, and it'll print a nice, readable representation of what your data structure looks like. Erasmus Darwin fucked around with this message at 14:35 on Aug 11, 2009 |
# ? Aug 11, 2009 00:00 |
|
Erasmus Darwin posted:
When you have multiple values for the same key like this, the last one wins. It's useful when you have a function that takes named parameters and you want to specify the defaults for some parameters: code:
When you have an odd-sized hash, the last key gets value undef. So in this case, %daddy_hash looks like: code:
|
# ? Aug 11, 2009 00:04 |
|
Sartak posted:useful stuff about named arguments Whenever I have a func that takes named arguments, I always seem to end up using them in a nested hash or something else later and wind up doing something like this code:
|
# ? Aug 11, 2009 00:28 |
|
|
# ? May 21, 2024 15:24 |
|
Be careful of using || as the "default" operator. What you really want is "defined-or" which was introduced in 5.10 as // (they lean). Careful cuz you know why, right? truthiness of zero
|
# ? Aug 11, 2009 00:46 |