|
What is a non-clunky way to generate an SSN? I have a working solution but I'm thinking there is a more elegant solution...Perl code:
*Hot drat, I'm really enjoying learning the powers of regular expressions. I created a new solution, not sure if its better or worse: Perl code:
Hughmoris fucked around with this message at 05:21 on Mar 30, 2015 |
# ? Mar 30, 2015 04:57 |
|
|
# ? May 17, 2024 07:13 |
|
Depending on how much you care about performance, probably faster to do something like $ssn = substr($ssn, 0, 3) . "-" . substr($ssn, 3, 2) . "-" . substr($ssn, 5, 4); (clunky compared to python's string slices, admittedly)
|
# ? Mar 30, 2015 05:25 |
|
Hughmoris posted:What is a non-clunky way to generate an SSN? I have a working solution but I'm thinking there is a more elegant solution... If someone else wants to handle a technical implementation of what you've written, by all means. But a valid US SSN has additional criteria beyond just being a series of 9 numbers that you'd probably want to take into account:
code:
|
# ? Mar 30, 2015 05:27 |
|
het posted:Depending on how much you care about performance, probably faster to do something like $ssn = substr($ssn, 0, 3) . "-" . substr($ssn, 3, 2) . "-" . substr($ssn, 5, 4); (clunky compared to python's string slices, admittedly) Thanks, that's what I was shooting for originally but I couldn't quite figure it out. Toshimo posted:If someone else wants to handle a technical implementation of what you've written, by all means. Hmmm. I honestly never paid much attention to the rules and regulations behind generating an SSN, learned something new today. For the purposes of my small project, I'm being lazy and including everything. Thanks for that info though. Hughmoris fucked around with this message at 06:01 on Mar 30, 2015 |
# ? Mar 30, 2015 05:57 |
|
If you have CPAN access, https://metacpan.org/pod/Data::Fake will give you:Perl code:
|
# ? Mar 30, 2015 15:21 |
|
EVGA Longoria posted:If you have CPAN access, https://metacpan.org/pod/Data::Fake will give you: I didn't even think to look on CPAN for a data generator. I need to poke around there a little bit more.
|
# ? Mar 31, 2015 02:54 |
|
code:
|
# ? Mar 31, 2015 03:12 |
|
uG posted:
|
# ? Mar 31, 2015 09:28 |
|
I'm trying to understand subroutines in perl. I'm following a short tutorial on Perl Maven and I'm unable to replicate the lesson: http://perlmaven.com/subroutines-and-functions-in-perl Here is what I have. Its supposed to take in a first and last name, then call the subroutine and print those names as an illustration of how parameters are handled. However, nothing is printing for me after I enter the two names. Perl code:
*Well poo poo, I think I misunderstood how the function works. I was thinking the function would print the names I entered but I guess it's printing the actual prompt ("First name: ) etc... I'm a dummy. Hughmoris fucked around with this message at 04:14 on Apr 1, 2015 |
# ? Apr 1, 2015 03:53 |
|
I'm fiddling around and trying to understand a little bit about APIs. For practice, I'm making a JSON call to rottentomatoes for any new dvd releases. Here is the returned dataset: http://pastebin.com/dEjuKAiZ My problem is that I don't know how to extract useful information from that dataset. For instance, if I wanted to return all the "title" values. Here is what I have so far from piecing together stackoverflow ideas. Any pointers? Perl code:
|
# ? Apr 4, 2015 03:27 |
|
Hughmoris posted:I'm fiddling around and trying to understand a little bit about APIs. For practice, I'm making a JSON call to rottentomatoes for any new dvd releases. Here is the returned dataset: http://pastebin.com/dEjuKAiZ Movies is an array of movies. You'd need to loop through it. Perl code:
|
# ? Apr 4, 2015 03:47 |
|
EVGA Longoria posted:Movies is an array of movies. You'd need to loop through it. Hmmm. I copied and ran your code and got an error "Not a hash reference at line 17" which is print "Movie Title: " . $movie->{title}; *Hopped on perl IRC and they helped me arrive to this solution, which will print out the title of each movie. I really need to sit down and try to understand how referencing and dereferencing works. Perl code:
Hughmoris fucked around with this message at 05:46 on Apr 4, 2015 |
# ? Apr 4, 2015 04:25 |
|
EVGA Longoria posted:Movies is an array of movies. You'd need to loop through it. After trying to understand referencing/dereferencing a little more (I still don't really get it), as an exercise I tried to figure out why the above code wouldn't work. It's missing the array dereference at this line: Perl code:
Perl code:
|
# ? Apr 4, 2015 16:27 |
|
Hughmoris posted:After trying to understand referencing/dereferencing a little more (I still don't really get it), as an exercise I tried to figure out why the above code wouldn't work. What version of perl are you running? They've changed a bunch of things with referencing at various points, so it might be that. Though I didn't test the code, so I might just be completely wrong. Also, the code they wrote uses $_ which is a magic variable and is sometimes bad practice, since it can change easily. EVGA Longoria fucked around with this message at 16:40 on Apr 4, 2015 |
# ? Apr 4, 2015 16:37 |
|
EVGA Longoria posted:What version of perl are you running? They've changed a bunch of things with referencing at various points, so it might be that. I'm using Strawberry Perl, v5.20.1 Yeah I know I shouldn't use the $_ operator but it's just cool to see how much information can be extracted using such a small amount of code.
|
# ? Apr 4, 2015 16:51 |
|
Hughmoris posted:After trying to understand referencing/dereferencing a little more (I still don't really get it) Hughmoris posted:I'm using Strawberry Perl, v5.20.1
|
# ? Apr 6, 2015 20:59 |
|
John Big Booty posted:All a reference is is a pointer to a value. To access or manipulate that value and its members, you have to dereference, using the infix operator (->) or the appropriate sigil. John Big Booty posted:Is Perl on Windows any less miserable than I remember? Its been working for me without any problems but I'm not really asking a lot of it, just basic learning/tutorials.
|
# ? Apr 7, 2015 00:03 |
|
Is there a clean and simple way to format text tables? Here is my output from grabbing the latest dvd releases and their release dates: code:
*Disregard, found something on CPAN (Text::Table) that makes it easy peasy. code:
Hughmoris fucked around with this message at 03:53 on Apr 7, 2015 |
# ? Apr 7, 2015 03:13 |
|
Is there a "say" equivalent that prints to STDERR? I've got a few scripts that I print warnings out to highlight bad data (so there's no need for line numbers) and remembering to put \n on the end of each string is a drag.
|
# ? Apr 7, 2015 06:55 |
|
Ephphatha posted:Is there a "say" equivalent that prints to STDERR? I've got a few scripts that I print warnings out to highlight bad data (so there's no need for line numbers) and remembering to put \n on the end of each string is a drag.
|
# ? Apr 7, 2015 07:02 |
|
Does anyone have any recommended readings or tips for learning how to scrape a webpage with perl? I'm wanting to scrape a local minor league baseball team's schedule for this year. It looks like the table that holds the dates is generated with javascript. The schedule is found here:http://www.milb.com/milb/stats/stats.jsp?t=t_sch&cid=4124&sid=t4124&stn=true I'm googling for some ideas but they seem to be all over the place, including using selenium, phantomJS, Mojo:OM and so on. Any tips on how to go about this? *Hopped on IRC #perl and someone opened my eyes on how to use the network analyzer tool in Chrome. I found where the schedule data is stored, and I'm thinking I'll have a much easier time parsing this: http://www.milb.com/gen/stats/jsdata/2015/clubs/t4124_sch.js?m=1428547560266 Hughmoris fucked around with this message at 04:09 on Apr 9, 2015 |
# ? Apr 9, 2015 02:50 |
|
This should definitely go in the Coding Horrors thread.
|
# ? Apr 9, 2015 04:28 |
|
Hughmoris posted:Does anyone have any recommended readings or tips for learning how to scrape a webpage with perl? My personal go-tos for that are WWW::Mechanize and HTML::Query. As an example, here's a recent thing I made, which scrapes some messages from a login-protected site to a JSON API.
|
# ? Apr 9, 2015 06:47 |
|
Im bad but you could wget or curl and pipe the output into your script as standard in via a cron.
|
# ? Apr 9, 2015 17:27 |
|
Salt Fish posted:Im bad but you could wget or curl and pipe the output into your script as standard in via a cron.
|
# ? Apr 10, 2015 22:30 |
|
I'm a big fan of Web::Scraper
|
# ? Apr 12, 2015 03:12 |
|
Sebbe posted:My personal go-tos for that are WWW::Mechanize and HTML::Query. leedo posted:I'm a big fan of Web::Scraper Thanks for these. I've been poking around with Web::Scraper and having a little bit of luck
|
# ? Apr 14, 2015 02:22 |
|
Using Perl in a Windows environment, is there a simple way to check if an application is open? In my script, I want to check if LotusNotes.exe is open before continuing. If it's not, I want to kill the script. Google is showing few examples and they seem a little beyond my understanding.
|
# ? May 3, 2015 03:57 |
|
https://metacpan.org/pod/P9Y::ProcessTable looks to be a cross platform implementation but for win32 ultimately wraps https://metacpan.org/pod/Win32::Process::Info and https://metacpan.org/pod/Win32::Process. I'd use the one that you grasp the api easiest on.
|
# ? May 3, 2015 05:43 |
|
Roseo posted:https://metacpan.org/pod/P9Y::ProcessTable looks to be a cross platform implementation but for win32 ultimately wraps https://metacpan.org/pod/Win32::Process::Info and https://metacpan.org/pod/Win32::Process. I'd use the one that you grasp the api easiest on. Thanks for this.
|
# ? May 4, 2015 13:06 |
|
Hughmoris posted:Using Perl in a Windows environment, is there a simple way to check if an application is open? In my script, I want to check if LotusNotes.exe is open before continuing. If it's not, I want to kill the script. Google is showing few examples and they seem a little beyond my understanding. Using a Perl script to automate Lotus Notes. The 90s are back.
|
# ? May 7, 2015 02:40 |
|
RICHUNCLEPENNYBAGS posted:Using a Perl script to automate Lotus Notes. The 90s are back. They never left. I'm not a programmer, was just looking for the easiest way to go about monitoring a Lotus Notes inbox for a work project. Strawberry Perl happen to work right out of the box, and I found a Perl script from 2003 that I could tweak to my purposes. I had a working solution in about 30 minutes. Very cool stuff.
|
# ? May 7, 2015 16:37 |
|
If I'm a dummy with little knowledge of Perl and no knowledge of web apps, is Dancer2 my easiest path to creating a simple web app?
|
# ? May 9, 2015 01:59 |
|
Hughmoris posted:If I'm a dummy with little knowledge of Perl and no knowledge of web apps, is Dancer2 my easiest path to creating a simple web app? Look at Dancer::Plugin::SimpleCRUD http://advent.perldancer.org/2011/2
|
# ? May 9, 2015 02:22 |
|
Roseo posted:Look at Dancer::Plugin::SimpleCRUD Thanks. I don't know if I'll even get that far as I can't successfully install Dancer2. On ubuntu, using the command "CPAN install dancer2" will do some processes and eventually display "Running Build install make test had returned bad status, won't install without force" before stopping the install. I then tried "cpan force install dancer2" and "cpan fforce install dancer2" and they both ended with the same result and same error message. Not sure where to go from here.
|
# ? May 9, 2015 02:42 |
|
Hughmoris posted:Thanks. I don't know if I'll even get that far as I can't successfully install Dancer2. On ubuntu, using the command "CPAN install dancer2" will do some processes and eventually display "Running Build install
|
# ? May 9, 2015 05:40 |
|
1 get on irc, the dancer people have a channel and love to help 2 to force install, launch the CPAN shell by calling cpan as it is, then run force install whatever 3 if tests fail on a cpan install, copy paste the whole output to gist.github.com or pastie.org, so people don't have to read your mind 4 get on irc, seriously (irccloud is a great free tool for that)
|
# ? May 9, 2015 12:56 |
|
John Big Booty posted:Which test failed? Lots and lots. Mithaldu posted:1 get on irc, the dancer people have a channel and love to help I took your advice and hopped on perl IRC. Someone was nice enough to help me out. They had me install the perl module local::lib for reasons I don't fully understand but I'm up and running now. Just created my first "Hello world!" web app. Hughmoris fucked around with this message at 04:12 on May 13, 2015 |
# ? May 13, 2015 01:54 |
|
Hughmoris posted:Lots and lots.
|
# ? May 13, 2015 17:17 |
|
|
# ? May 17, 2024 07:13 |
|
John Big Booty posted:This is never the right answer. I'm pretty unfamiliar with how modules are installed but it seemed like everything failed. Unfortunately I didn't save a copy of the log before I fixed the problem so I can only give vague answers
|
# ? May 13, 2015 17:43 |