|
wolffenstein posted:I created and used a XML However, if you find that you have requirements like you described, then you need a real drat database. Something like DBD::SQLite will give you all the power of SQL, but still contain the data to a single file you can carry around. In summary: Some people who have a problem think they'll use XML. Now they have two problems.
|
# ? May 28, 2011 20:19 |
|
|
# ? Jun 3, 2024 18:10 |
|
Yeah okay I'll go back in time and tell intern me to not use XML.
|
# ? May 28, 2011 20:33 |
|
uG posted:How would I check that if i'm making my requests with LWP? Or will I need to use an actual socket? Something similar to this should work: code:
|
# ? May 29, 2011 23:47 |
|
Ok I got another one. I picked up a quick job on vworker for a forked/threaded brute force script, easy enough. According to the buyer, he should be able to run more than 10 forks, its slow, and his PHP script is faster. I can't see how to make this significantly more efficient though. http://www.ugexe.com/brute.txt I mean i'm sure there are better ways to iterate over some things, but I imagine my problem is with the forks and the LWP connections. Also i'm not very fond of using IPC::ShareLite, and i'm not sure how to remove it from memory when i'm done.
|
# ? Jun 2, 2011 03:19 |
|
uG posted:Ok I got another one. I picked up a quick job on vworker for a forked/threaded brute force script, easy enough. According to the buyer, he should be able to run more than 10 forks, its slow, and his PHP script is faster. I can't see how to make this significantly more efficient though. Actually, I'd guess you're hanging on the LWP blocking operation. You may want to try an asynchronous HTTP get (such as AnyEvent::HTTP) that'll continue working as it waits for a response. You may also want to run it through Devel::NYTProf and figure out for certain where it's slow, not simply guess.
|
# ? Jun 2, 2011 05:26 |
|
Roseo posted:Actually, I'd guess you're hanging on the LWP blocking operation. You may want to try an asynchronous HTTP get (such as AnyEvent::HTTP) that'll continue working as it waits for a response. You may also want to run it through Devel::NYTProf and figure out for certain where it's slow, not simply guess.
|
# ? Jun 2, 2011 16:42 |
|
This is probably ridiculously easy, but for some reason (whether it's because my brain is dry from all the coding I've been doing or that it's early and I haven't had coffee yet), I cannot figure out how to do it. I want to generate an array containing a list of the past 12 hours, in 24 hour format, from the current hour. So it should be a list similar to: 19:00 20:00 21:00 22:00 23:00 00:00 01:00 02:00 ...and so on, with the array ending with the current hour. This can't be THAT tough, can it?
|
# ? Jun 5, 2011 13:24 |
|
Accipiter posted:This is probably ridiculously easy, but for some reason (whether it's because my brain is dry from all the coding I've been doing or that it's early and I haven't had coffee yet), I cannot figure out how to do it.
|
# ? Jun 5, 2011 15:25 |
|
Accipiter posted:This is probably ridiculously easy, but for some reason (whether it's because my brain is dry from all the coding I've been doing or that it's early and I haven't had coffee yet), I cannot figure out how to do it. perl -e 'printf( "%02d:00\n", $_ % 24 ) for ( ( (localtime)[2] - 11) .. (localtime)[2] )' or, if you want an array: perl -e 'my @a = map {sprintf( "%02d:00", $_ % 24 )} ( ( (localtime)[2] - 11) .. (localtime)[2] ); print "$_\n" for @a' I'll let you clean it up however you want. Anaconda Rifle fucked around with this message at 15:44 on Jun 5, 2011 |
# ? Jun 5, 2011 15:42 |
|
One caveat: The suggestions so far ignore the transition to/from Daylight Savings. Depending on what you're doing this for, you may or may not need it to handle those cases correctly. I believe when DST starts, it looks like: 23:00, 00:00, 01:00, 03:00, 04:00, 05:00 And when it ends: 23:00, 00:00, 01:00, 02:00, 02:00, 03:00 If you need to handle this case (say because you're listing shifts at a hospital that runs 24/7/365), then I'd suggest something like this: code:
|
# ? Jun 5, 2011 19:26 |
|
Good call, Erasmus Darwin. I didn't even consider that.
|
# ? Jun 5, 2011 22:00 |
|
code:
Edit: Fixed to handle the hh:mm formatting. Roseo fucked around with this message at 22:07 on Jun 5, 2011 |
# ? Jun 5, 2011 22:03 |
|
...so I WAS laughably wrong. But the last three solutions are a perfect illustration of why I love perl. Good perl is clever, awesome, and aesthetically pleasing all at once.
|
# ? Jun 5, 2011 22:13 |
|
Is there an alternative to I18N::Langinfo for Perl on Windows? It seems that it's not built into Windows Perl builds due to the lack of an nl_langinfo() implementation in Windows. I need to be able to find out what encoding I should be expecting from terminal reads. (It uses Term::ReadLine to read lines from the terminal, but unfortunately Term::ReadLine doesn't handle translating into Perl's internal UTF8(-esque?) string representation.) And yes, I've tried Google, but it seems to be failing me. (Or I'm just dumb.)
|
# ? Jun 6, 2011 19:39 |
|
Not really related but tchrist's recent UTF8 post is pretty fantastic: http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/6163129#6163129
|
# ? Jun 6, 2011 20:30 |
|
Mario Incandenza posted:Not really related but tchrist's recent UTF8 post is pretty fantastic: Yeah, I misspoke, it's not really accurate to refer to the internal string format as UTF8. But whatever the case...
|
# ? Jun 6, 2011 21:21 |
|
I've been using pQuery for web scraping, and have seen Web::Scraper get mentioned as well. What do you guys use for scraping js/ajax heavy sites? Google is pretty much pointing me towards Selenium.
|
# ? Jun 8, 2011 07:26 |
|
You're the first person I've seen who uses pQuery. Do you like it? Selenium is worth trying, definitely. Alien::Selenium may or may not make your life easier. PhantomJS is an up-and-comer too. It's a headless webkit. It's not as entrenched as Selenium but the idea is pretty neat.
|
# ? Jun 8, 2011 09:28 |
|
Filburt Shellbach posted:You're the first person I've seen who uses pQuery. Do you like it? I've never run Selenium before, but I am worried about the number of browser instances I may need loaded up (if it will be a memory problem). PhantomJS looks promising, just wish it has a nice Perl interface like Selenium. uG fucked around with this message at 05:08 on Jun 9, 2011 |
# ? Jun 8, 2011 15:43 |
|
I'm trying to run PAR Packer and I get this error: Perl lib version (5.10.0) doesn't match executable version (v5.10.1) How do I fix this? I tried to upgrade ActivePerl but I keep getting an error "The selected directory contains an incompatible version of ActivePerl. Please choose a different installation location". Google returns zilch for that message. How do I upgrade Perl without losing all my installed modules and stuff?
|
# ? Jun 10, 2011 17:23 |
|
Schweinhund posted:I'm trying to run PAR Packer and I get this error:
|
# ? Jun 10, 2011 17:35 |
|
Never heard of it before. I think I just googled "Perl for windows" and installed that.
|
# ? Jun 10, 2011 18:20 |
|
Is there some way to do prompted input (stdin, not command line) into perl with filesystem-searching tab completion? There's Term::Complete, but that only works on a list of arguments you supply. I'm having difficulty believing there isn't a working solution for this, but I guess interfacing with the terminal can be prickly.
|
# ? Jun 23, 2011 19:48 |
|
The word you want for that is ReadLine, which emulates a shell-like environment. Term::ReadLine is the standard there, but it's not great. Term::ReadLine::Gnu can sometimes make it better.
|
# ? Jun 24, 2011 00:45 |
|
Devel::REPL has a bunch of tab completion plugins, I can't imagine it would be difficult to hack something up for that.
|
# ? Jun 26, 2011 17:56 |
|
Mario Incandenza posted:Devel::REPL has a bunch of tab completion plugins, I can't imagine it would be difficult to hack something up for that. I hope it's not. I did write all of Devel::REPL's tab completion functionality.
|
# ? Jun 26, 2011 21:48 |
|
Has anyone else had problems with pp including every single installed module instead of just the ones the script you're trying to pack depends on? I'm using strawberry perl, the latest version, and the latest PAR::Packer on Windows 7 64-bit. I did some experimenting a while back, and it looked to me like scandeps wasn't working or something, because I was literally getting a list of everything I had installed. If there's a fix, or if it's because I'm doing something stupid, I'd love to know. Right now, when I make a PAR or executable, I'm using -n and manually including each module and dll, which is kind of a pain, but the difference is pretty clear. For instance, I had a short script that I tried to make into a PAR, and the PAR size was around 3Mb, but when I redid it using -n and just the modules I knew it needed, it went down to something like 100k. So, have you seen this? Am I doing something dumb? I've searched everywhere to see if anyone's having the same problem, and it doesn't look that way, so I'm thinking I just don't know what I'm doing.
|
# ? Jun 26, 2011 21:56 |
|
Sizzler Manager posted:Has anyone else had problems with pp including every single installed module instead of just the ones the script you're trying to pack depends on? I'm using strawberry perl, the latest version, and the latest PAR::Packer on Windows 7 64-bit. I did some experimenting a while back, and it looked to me like scandeps wasn't working or something, because I was literally getting a list of everything I had installed. If there's a fix, or if it's because I'm doing something stupid, I'd love to know. Right now, when I make a PAR or executable, I'm using -n and manually including each module and dll, which is kind of a pain, but the difference is pretty clear. For instance, I had a short script that I tried to make into a PAR, and the PAR size was around 3Mb, but when I redid it using -n and just the modules I knew it needed, it went down to something like 100k. So, have you seen this? Am I doing something dumb? I've searched everywhere to see if anyone's having the same problem, and it doesn't look that way, so I'm thinking I just don't know what I'm doing.
|
# ? Jun 30, 2011 04:08 |
|
uG posted:Not only do I have that problem, but it often leaves out a bunch of modules that are required unless I -n them. The only packager I ever had luck with was perl2exe, which apparently sucks. On a separate topic - and this is driving me nuts - when you create a module, how do you automatically move sample scripts to your installation directory when you do a make install, or better yet, create perl scripts wrapped in windows batch files? I can see that a lot of modules I've installed do this, and I'd really like to do the same thing with a module I'm working on, but I'm damned if I can figure out how. I'm actually using Module::Build, if that makes a difference. Edit: Nevermind, I'm just dumb. All you have to do is create a bin folder in the distribution and stick perl scripts in there. Build install automatically runs pl2bat on them and sticks them in perl/site/bin. MacGowans Teeth fucked around with this message at 20:27 on Jul 1, 2011 |
# ? Jun 30, 2011 13:04 |
|
Noob question. I have an input set to a paragraph and i need to remove its sentences from first to last and save them as their own variables. I've just been introduced to regular expressions and thought that something along the lines of this should work: code:
|
# ? Jul 5, 2011 19:31 |
|
Back Stabber posted:Noob question. If you're basically just splitting on periods, why not just use split() with that same regular expression? ($sentence) = ($paragraph =~ /^.*\./) doesn't work because the right side is evaluating to 1 (successful match). Also, the * is greedy, so it will match as far to the right as it can. You can make it lazy by putting a ? after it. If you use code:
|
# ? Jul 5, 2011 20:17 |
|
code:
Or you can split on periods like it was mentioned above: code:
uG fucked around with this message at 23:14 on Jul 5, 2011 |
# ? Jul 5, 2011 23:09 |
|
Or you can use CPAN and a module like Lingua::Sentence.code:
|
# ? Jul 5, 2011 23:37 |
|
I'm looking to step through an array 50 at a time, to batch a set of requests to a server in BioPerl. However, the system I'm on can't seem to use natatime, despite my extensive efforts. Is there an easy way to get rid of natatime in this code?code:
|
# ? Jul 6, 2011 17:01 |
|
code:
Mario Incandenza fucked around with this message at 19:25 on Jul 6, 2011 |
# ? Jul 6, 2011 19:22 |
|
Mario Incandenza posted:
You probably want a <, not a >=.
|
# ? Jul 6, 2011 19:24 |
|
natatime is pure perl, if worst comes to worse you can use the List::MoreUtils function by putting it in your namespace:code:
|
# ? Jul 7, 2011 02:19 |
|
I'm using this code, and it works, but it seems overly complicated to me. Basically, I'm starting with @list, which contains hash references, each of which has a Parent (which is just a scalar value matching an ID somewhere else), a Type, and a Rank. For each set of hash refs with the same parent, if there are multiple refs with the same value in Type, their Ranks must be unique. Is there a better/simpler way to do this?code:
Any thoughts? Or, more generally, is there anything horrible or non-idiomatic about this code? I've only been using Perl for a few months, so I'm sure there's a lot I could do better.
|
# ? Jul 7, 2011 16:14 |
|
Are you just trying to create a list of unique entries in @list, where uniqueness is defined as not having the exact same combination of parent, type, and rank as another entry? If so, what about just serializing those three values and using them as a hash key?code:
|
# ? Jul 7, 2011 19:50 |
|
|
# ? Jun 3, 2024 18:10 |
|
Erasmus Darwin posted:Are you just trying to create a list of unique entries in @list, where uniqueness is defined as not having the exact same combination of parent, type, and rank as another entry? If so, what about just serializing those three values and using them as a hash key? drat, I never thought about it that way. Yes, that simplifies it a lot. I knew I was over-complicating things. Thanks!
|
# ? Jul 7, 2011 20:07 |