|
qntm posted:
This should be: code:
|
# ? May 16, 2012 18:02 |
|
|
# ? May 21, 2024 22:13 |
|
On this page: http://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=y&type=8&season=2012&month=0&season1=2012&ind=0 1/3 of the way down is a link called "export data". When you click it, it's a download link to a spreadsheet. I'd like to be able to download that spreadsheet automatically without clicking the link. The problem is it's a javascript link, so I'm not sure it's possible to get with Perl. Is there anyway to do it? It doesn't have to be a perl solution really. I just need something that will run on windows and download that link every day. I'd guess there may be a PHP equivalent to that link I could use with perl, but I'm not sure how to generate that.
|
# ? Jun 10, 2012 11:26 |
|
Schweinhund posted:On this page: Rohaq fucked around with this message at 14:14 on Jun 10, 2012 |
# ? Jun 10, 2012 14:02 |
|
looking at the source is easy enough man. there is a form with the id "form1", it has a bunch of hidden input vars. the javascript link does nothing but post using that form. and as the post above says, "LB$cmdCSV" is the eventTarget. there is no eventArgument. you could probably craft a couple of curl requests to ge tthe data but theres a worryingly long session var that might get in the way. I'd probably use WWW::Mechanize to grab the form, set the __EVENTTARGET to "LB$cmdCSV", and then post it off. You should get the raw data as a response. Perl code:
|
# ? Jun 11, 2012 07:41 |
|
TiMBuS posted:looking at the source is easy enough man. I tried but I haven't really dealt with web stuff in a while so it was pretty confusing. That works, thanks a lot.
|
# ? Jun 11, 2012 13:25 |
|
TiMBuS posted:looking at the source is easy enough man. there is a form with the id "form1", it has a bunch of hidden input vars.
|
# ? Jun 11, 2012 16:18 |
|
For those of you who couldn't attend YAPC::NA, here's a bunch of videos from the third day: http://www.youtube.com/playlist?list=PLE3F888A650339DDF
|
# ? Jun 16, 2012 05:49 |
|
Perl saved me a bunch of time today. Like, a whole bunch. And I think made me look good to my coworkers and boss. Thank you Larry Wall, you crazy diamond It was also nice to take a break from thinking about special function registers and clocks causing noise on the ADC and the like for a while here in microcontroller-land. Blotto Skorzany fucked around with this message at 23:36 on Jun 18, 2012 |
# ? Jun 18, 2012 23:09 |
|
You can do inline asm in perl if you want. Best of both worlds
|
# ? Jun 18, 2012 23:28 |
|
Any regular expression gurus in the house? We have a custom template file that denotes variables wrapped in ??'s. Here's some example data:code:
code:
|
# ? Jun 19, 2012 00:49 |
|
You need to add that ? to the quantifier (your +) to make it non-greedy (so you'd end up with \S+?). You're using it as a zero-or-one quantifier on a group around the entirety of the regexp, which isn't going to do what you want it to.
|
# ? Jun 19, 2012 01:16 |
|
Thanks. Every time I think I understand regular expressions, something like this throws me a curve ball!
|
# ? Jun 19, 2012 01:26 |
|
syphon posted:Thanks. Every time I think I understand regular expressions, something like this throws me a curve ball! Also, that feature is great for building more efficient expressions. The following is more efficient than your expression above, for example, since it doesn't constantly check for the existence of "??" after your capture group: code:
|
# ? Jun 19, 2012 10:51 |
|
It's also different because [^(?:\?\?)] is a character class (i.e. it doesn't mean "not ??", it means "none of the characters (, ), ?, :"). The closest thing you can get with character classes is [^?] but then ??foo?bar?? will not match.
|
# ? Jun 19, 2012 11:15 |
|
Isilkor posted:It's also different because [^(?:\?\?)] is a character class (i.e. it doesn't mean "not ??", it means "none of the characters (, ), ?, :"). The closest thing you can get with character classes is [^?] but then ??foo?bar?? will not match. code:
|
# ? Jun 19, 2012 13:44 |
|
Generating 226 S19 eeprom images in various configs using Moose : 68 seconds Generating 226 s19 eeprom images in various configs using Mouse : 14 seconds Generating 226 s19 eeprom images in various configs using Moose*: 1.8 seconds *Don't be a moron and exec a script once per file for 226 files when you could exec it once and loop over the loving files
|
# ? Jun 20, 2012 15:22 |
|
Otto Skorzeny posted:Generating 226 S19 eeprom images in various configs using Moose : 68 seconds Now try with Moo.
|
# ? Jun 23, 2012 03:53 |
|
Well okay. I've never seen Moo outperform Mouse. The only advantage I've seen is that it can work with Moose, whereas Mouse + Moose can collide on occasion. If we need proof though: Startup time. After 10 runs of each to avoid cold code: code:
code:
Oh and while I'm at it: code:
|
# ? Jun 24, 2012 07:08 |
|
Before I get called a liar, I modified the code to put ->new into each test run so we are now actually benchmarking object creation. I also added a Moo class that didn't validate the int -at all- code:
|
# ? Jun 24, 2012 07:31 |
|
Moo will use Class::XSAccessor for simple accessors if it is available, which in my testing makes it faster than Mouse for that case.
|
# ? Jun 24, 2012 09:27 |
|
You're right. Thats not even in the Moo docs :/ I now get slightly faster Moo accessors but only if it's not doing any validation (which is never, in my code). Object instantiation is still much slower, startup time is the same. Overall benchmark (creation+validation+accessor) still puts Moo at ~2.5x slower (same bench result as the previous post). Stickin' with Mouse.
|
# ? Jun 24, 2012 09:51 |
|
TiMBuS posted:Well okay. I've never seen Moo outperform Mouse. The only advantage I've seen is that it can work with Moose, whereas Mouse + Moose can collide on occasion. Also, aside from being a smooth upgrade to Moose, the main advantages to Moo are that it is pure perl and thus easier to debug when stuff does go wrong, and comes with zero dependencies requiring a compiler, meaning that you can easily bundle it it for outdated clients or similar situations.
|
# ? Jun 28, 2012 10:58 |
|
I'm trying to print lines from a flat file that have a string match of '3133' in a certain position but can';t figure out a good way to move to position 1224, examine the next 4 bytes, and if they match, print the line out. Eventually I'd like to dump this out to a file. Any pointers?
|
# ? Jul 5, 2012 21:12 |
|
raej posted:I'm trying to print lines from a flat file that have a string match of '3133' in a certain position but can';t figure out a good way to move to position 1224, examine the next 4 bytes, and if they match, print the line out. Position 1224 of the file, or position 1224 of each line in a file?
|
# ? Jul 5, 2012 21:17 |
|
Anaconda Rifle posted:Position 1224 of the file, or position 1224 of each line in a file? Each line. See attached image. I want to print all of the lines out, except for lines 2 and 5.
|
# ? Jul 5, 2012 21:32 |
|
raej posted:Each line. See attached image. I want to print all of the lines out, except for lines 2 and 5. I'd probably use unpack or a really lovely regex. How large are these files? Might want to benchmark both approaches.
|
# ? Jul 5, 2012 21:37 |
|
Anaconda Rifle posted:I'd probably use unpack or a really lovely regex. How large are these files? Might want to benchmark both approaches. 1254 bytes in length, ~50k lines for this guy.
|
# ? Jul 5, 2012 21:42 |
|
raej posted:I'm trying to print lines from a flat file that have a string match of '3133' in a certain position but can';t figure out a good way to move to position 1224, examine the next 4 bytes, and if they match, print the line out. Obviously you can flesh this out more but I think this should do what you want. Perl code:
|
# ? Jul 5, 2012 21:49 |
|
het posted:Obviously you can flesh this out more but I think this should do what you want. This was it, perfect, thank you!
|
# ? Jul 5, 2012 21:56 |
|
Wow. I completely forgot substr existed. Where do I hand in my Perl badge?
|
# ? Jul 5, 2012 22:21 |
|
I never use substr in favor of regular expressions, nowadays. I rarely seem to process strings on consistent length where substr would actually be useful.
|
# ? Jul 5, 2012 22:44 |
|
syphon posted:I never use substr in favor of regular expressions, nowadays. I rarely seem to process strings on consistent length where substr would actually be useful. I use substr and unpack all the time, but I work with a LOT of fixed length records, because this industry (insurance) is still in the COBOL mindset, I think.
|
# ? Jul 6, 2012 02:01 |
|
I work with pack a bunch because it's a pretty reasonable way to pack things into s-records
|
# ? Jul 6, 2012 03:43 |
|
I discovered WWW::Mechanize today. It's pretty fun.
|
# ? Jul 6, 2012 16:55 |
|
I teaching myself Perl this summer, and I am working on problem about regular expression matching. The problem has me stripping html tags out of text, stuff like <br> turning into new lines, and I have all of that working correctly. However, the part I am stuck is putting dashes around all words contained within <em> and </em> tags. I really don't know where to start with this, besides what I've read about matching full words in RE via /b. Should I do an if-check on if <em> is found, and then throw the rest of the text between until it finds </em> into an array, and then add the dashes around each array items using a foreach? I can't seem to figure out an easy way to do 'look forward' for the closing </em> once the initial <em> is found. Example input: <em>This is a test Okay</em> Output: -This- -is- -a- -test- -Okay- jeeves fucked around with this message at 19:59 on Jul 16, 2012 |
# ? Jul 16, 2012 19:47 |
|
Not to rain on your parade but the real answer is seriously "don't use regexps to parse html", it's the wrong tool for the job, you're better off using a module that'll parse it for you. That said, you can use s///m for multi-line matching.
|
# ? Jul 16, 2012 20:07 |
|
het posted:Not to rain on your parade but the real answer is seriously "don't use regexps to parse html", it's the wrong tool for the job, you're better off using a module that'll parse it for you. Yeah, I figured that there is a better way to do this, but I have just been doing the example questions and it seems whoever wrote this thought that this would be a good question for a RE substitution chapter or such. Thanks for multi-line matching though, I'll look into that. jeeves fucked around with this message at 20:20 on Jul 16, 2012 |
# ? Jul 16, 2012 20:10 |
|
The easiest / laziest thing I can think of is just to set a flag if there's an open <em> tag and then look for a closing tag instead while outputting appropriately. And (efb of course) people are going to yell at you for trying to parse html with regexps in the first place.
|
# ? Jul 16, 2012 20:10 |
|
spoon0042 posted:The easiest / laziest thing I can think of is just to set a flag if there's an open <em> tag and then look for a closing tag instead while outputting appropriately. I didn't think to set a flag and then automatically add dashes while also looking for the closing tag. Much easier than first trying to find then closing tag and then processing the in between text after. Thanks! And yeah, if this question was for a modules chapter I am sure I would use a module, but it was written for a RE chapter so oh well
|
# ? Jul 16, 2012 20:20 |
|
|
# ? May 21, 2024 22:13 |
|
jeeves posted:I teaching myself Perl this summer, and I am working on problem about regular expression matching. This isn't exactly what you're asking for, but you might be able to use it. I wrote (i.e., found on Perl Monks and then slightly modified) this to pull XML out of a bunch of log files a while back. code:
|
# ? Jul 16, 2012 20:47 |