|
TheHeadSage posted:I've been given the task to write the new perl DB Backup management script at work, as clients now want database backups every half hour or 15 minutes instead of the 1 hour we had beforehand. Now, there are about 30 websites on the server, each with a db size of about 300mb. Set up another server with whatever DB you're using and set the first one up to replicate to the second one (google for guides). That way you get a backup that's constantly up-to-date and can be switched over to with a minimum of effort in case the first one shits the bed. Using a Perl script to backup a 300MB database every 15 minutes is silly.
|
# ? Sep 21, 2009 09:15 |
|
|
# ? May 21, 2024 20:18 |
|
Also have a look at XtraBackup from Percona.
|
# ? Sep 22, 2009 11:59 |
|
Does anyone know of any sockets wrapper that will handle retries, timeouts, etc, and just let me pass a couple of subroutine references to use to encode the outgoing transmissions with and use to determine how many bytes to read and decode the incoming transmissions? I've got a client module that works when the network conditions are fine but is running into issues with packetloss, etc. Ideally, I'd like something I can use or subclass that I can give a string, let it handle the details of making sure the transmission/reception of response is fault-tolerant, and give me the resulting string back. Alternately, I'm trawling the web for decent references in what possible error conditions and states that I need to handle using IO::Socket::INET there are. If anyone knows of decent resources alone these lines it'd be much appreciated.
|
# ? Sep 23, 2009 22:06 |
|
I used AUTOLOAD for the first time today. Yesterday I used magic goto. I feel dirty
|
# ? Oct 13, 2009 03:55 |
|
Which goto form is magic? You mean goto EXPRESSION which calculates the label to jump to, right? If so I'd like to see that code. I've never seen that beast in the wild.
|
# ? Oct 13, 2009 04:05 |
|
goto &function It's somewhat similar to the usage in Help.pm e: basically I'm writing some code to eliminate boilerplate in cheesebot, the git repo of which I'm puting up soonish Blotto Skorzany fucked around with this message at 04:19 on Oct 13, 2009 |
# ? Oct 13, 2009 04:17 |
|
Oh, pfft, do not feel dirty about goto CODEREF. It's just tail call optimization. AUTOLOAD though? Boy, you so nasty.
|
# ? Oct 13, 2009 04:19 |
|
Aside from a CS course several years ago taught in perl I have never had any particular reason to use the language, and I probably won't be using it much in the future. I am stuck on a small issue in modifying Plans Calendar, and I think (assume?) this will be very easy for anyone who works in the language. Plans has a very useful feature where it will generate a list of upcoming events for the next X days. The annoying thing is that it does not provide a parameter to limit the number of upcoming events; for the template I am developing I would like to have up to Y events for the X upcoming days. So far I have been able to pass the script a new parameter and have set up a foreach loop which will break when Y events have been reached. My trouble is that I need to sort the array of events by date before limiting it to Y in number so that it returns the first Y events rather than Y events in the order they were added to the database. Here's the code as it stands right now, where I get $results back with Y events but those events are not in chronological order: code:
|
# ? Oct 19, 2009 02:52 |
|
Eurgh, that's really terrible Perl. The snippet you posted doesn't point to any obvious date attributes, so it's kinda hard to tell you how to modify it to sort by them.
|
# ? Oct 19, 2009 04:02 |
|
atomicstack posted:Eurgh, that's really terrible Perl. The snippet you posted doesn't point to any obvious date attributes, so it's kinda hard to tell you how to modify it to sort by them. Ouch, not what I was hoping to hear. But a thought-provoking comment nonetheless. I am digging around in the source and I see now that the sorting is done client-side in javascript. I still think that it would be better to sort and limit the output on the server side but I'd be satisfied to get this working correctly for the time being. Maybe it's going to be harder than I thought though. I'm working through that JS code right now to find some meaningful excerpts and it is pretty hard to summarize the presentation logic. Maybe that is just Plans being consistent in being squirrelly.
|
# ? Oct 19, 2009 13:17 |
|
I was going to suggest checking the load_events sub to see if you could modify the query string used to retrieve events from the database, but then I took a look at some of the code from the backend and decided to go do something else
|
# ? Oct 19, 2009 13:29 |
|
atomicstack posted:I was going to suggest checking the load_events sub to see if you could modify the query string used to retrieve events from the database, but then I took a look at some of the code from the backend and decided to go do something else It is probably not pertinent to mention that I am using 7.10 (the new version 8 still seems a little wobbly). I am sad that it seems like Plans is not the answer to my situation. It has not been easy to find a calendar that I can just plug in to whatever project I am working on. I have used a couple in the past, and none of them just work the way Plans (almost) does for my circumstances. I still have this notion that if I can isolate the sorting logic in the JS maybe there is a way to modify the script to do this one simple thing. Thanks for the effort so far though.
|
# ? Oct 19, 2009 19:40 |
|
Here's the deal: You can very rapidly asses the quality of any Perl code by looking at the first few lines. Do you see "use strict;" and possibly "use warnings;" anywhere? If not, it's poo poo code. This whole thing might as well be in PHP right now. As such you really have only two paths: 1. Learn Perl and clean it up (using Perl Best Practices as guidance anyone should be able to) 2. Pay someone else to clean it up.
|
# ? Oct 19, 2009 19:56 |
|
Mithaldu posted:Here's the deal: You can very rapidly asses the quality of any Perl code by looking at the first few lines. Do you see "use strict;" and possibly "use warnings;" anywhere? If not, it's poo poo code. This whole thing might as well be in PHP right now. Fair enough. I am compelled to point out the irony that I want to use this script to integrate with a PHP CMS. If I wasn't working full time I'd be inclined to learn perl and clean it up. On the other hand, I'm interested in using Plans in my workplace, so I'd be willing to entertain any proposals (in this thread or via PM) on how much time billable time it would take one of you fine folks to clean it up on my behalf. Unless of course we are talking about adding "use strict;" to the top and then spending a couple hundred hours rebuilding the whole thing. That would be outside my financial means. (Please feel free to do so as a volunteer though -- they evidently could use a hand. I'll beta test!)
|
# ? Oct 19, 2009 22:57 |
|
It makes me a little bit sad, but I went ahead and implemented this on the client side. At least it works for now.
|
# ? Oct 23, 2009 13:42 |
|
Not sure if this has been posted here before, but chromatic's blog is well worth following. Especially his latest post should be read by everyone, literally: http://www.modernperlbooks.com/mt/2009/11/from-novice-to-adept-the-act-of-naming.html
|
# ? Nov 5, 2009 03:50 |
|
I have a question about how unix system commands work in perl. I have my PATH environment variable set to the directory of a program I want to run. I can type: > my_program my_program executed However, if I try the same thing in my perl script with this line: print `my_program`; I get the error message, "Can't exec "my_program": No such file or directory at ../test.pl line 11." Why is this so?
|
# ? Nov 9, 2009 00:49 |
|
It's running it from the current working directory. It has nothing to do with your environment variables.
|
# ? Nov 9, 2009 01:25 |
|
Triple Tech posted:It's running it from the current working directory. It has nothing to do with your environment variables. What? No, UNIX doesn't exec programs from the cwd unless "." is a member of the PATH environment variable. It has everything to do with his PATH. octobernight: Have your perl program print the contents of $ENV{"PATH"} to verify that it is correct; there may be some subtlety in how you are starting your perl program that is preventing it from inheriting the environment you think it is.
|
# ? Nov 9, 2009 01:30 |
|
But it will not execute stuff from the current working directory if the current working directory is not in the PATH. (e:f;b)
|
# ? Nov 9, 2009 01:31 |
|
I might be talking out of my bum. I'm sorry.
|
# ? Nov 9, 2009 02:01 |
|
ShoulderDaemon posted:What? No, UNIX doesn't exec programs from the cwd unless "." is a member of the PATH environment variable. It has everything to do with his PATH. I had perl print the $ENV{"PATH"} and it did show up correctly. I also checked and "." is on my PATH environment variable. I'm really stumped whether this is a perl problem or a unix problem.
|
# ? Nov 9, 2009 02:08 |
|
octobernight posted:I had perl print the $ENV{"PATH"} and it did show up correctly. I also checked and "." is on my PATH environment variable. I'm really stumped whether this is a perl problem or a unix problem. I'd check for something like an invisible unicode character or similar in the `` in your perl program. If you use something like `/full/path/to/my_program` does it work? Also, having "." in your PATH is not normally considered a good idea.
|
# ? Nov 9, 2009 02:45 |
|
ShoulderDaemon posted:I'd check for something like an invisible unicode character or similar in the `` in your perl program. If you use something like `/full/path/to/my_program` does it work? I checked for any invisible characters and couldn't find any. I also tried using the full path, and it worked correctly. Very strange. Here's the error message I am receiving: #This works print `~/programs/my_program/bin/my_program -help`; #This doesn't work print `my_program -help` Can't exec "my_program": No such file or directory at ./test.pl line 15. #This works on the unix command line in any other directory > my_program -help I also removed the "." from my path. I only added to test if that could've been a problem. Thanks for all your help, though. It's just that this problem doesn't make too much sense to me.
|
# ? Nov 9, 2009 03:24 |
|
octobernight posted:(environment variable shenanigans) Well, when perl handles backticks it invokes a subshell; it's possible that the subshell's init process is overwriting your PATH variable. Check the output of print `echo \$PATH` and report if that is correct.
|
# ? Nov 9, 2009 06:29 |
|
FindBin (part of the core) will be useful here, if the script you're trying to run is located in the same directory as your Perl:code:
Mario Incandenza fucked around with this message at 07:34 on Nov 9, 2009 |
# ? Nov 9, 2009 07:19 |
|
ShoulderDaemon posted:Well, when perl handles backticks it invokes a subshell; it's possible that the subshell's init process is overwriting your PATH variable. I checked that, and the program does display on the correct path. Since I'm on such a tight time constraint, and I am only verifying another project, I think I'll hardcode in the path for now. I will need to figure out why this isn't working later. Thank you for all your help, though. Mario Incandenza posted:FindBin (part of the core) will be useful here, if the script you're trying to run is located in the same directory as your Perl: I will try this later tonight once I read more about how FindBin works. Thanks for the link.
|
# ? Nov 9, 2009 23:05 |
|
So suppose I have an array of ranges. Something likecode:
|
# ? Nov 21, 2009 00:03 |
|
Number::Range
|
# ? Nov 21, 2009 00:07 |
|
Filburt Shellbach posted:Number::Range gently caress yeah. Thanks.
|
# ? Nov 21, 2009 00:14 |
|
Don't you just love it when a reference is accidentally numified and passed through to your merchant account as a $166m charge against a dummy card number and the bank locks down your payment gateway as a result?
|
# ? Nov 27, 2009 11:09 |
|
Code posted:@output = `./cs216program5 $search $searchinfo`; Output posted:output = _223315_Daniels_Tom_April 02, 1990_2E_DNA1.data_ I have no idea why I get a 1 back after the split. Could there be something wrong with the way I am using split? I tried splitting on /_/ too but that does the same thing. I have also tried @output = split ( "_" , `./cs216program5 $search $searchinfo`); but nothing seems to come back. White-Lightning fucked around with this message at 00:11 on Dec 4, 2009 |
# ? Dec 4, 2009 00:07 |
|
White-Lightning posted:I have no idea why I get a 1 back after the split. Could there be something wrong with the way I am using split? I tried splitting on /_/ too but that does the same thing. @output is an array, but split expects a scalar in the second position, and because it's a builtin (and, thus, prototyped) it will coerce your array to scalar context, which does not concatenate its members (as you may expect) but instead simply calculates the length of the array. So, your code is the same as @output = split( "_", length @output );, which obviously is @output = split( "_", 1 ); as the backticks returned a single element in this case, and is clearly not what you want. Here's the fix: code:
|
# ? Dec 4, 2009 00:15 |
|
code:
$output = `./cs216program5 $search $searchinfo`; so I tried it as @output = split( "_", `./cs216program5 $search $searchinfo` ); print "output after split = @output"; but that doesnt return anything.
|
# ? Dec 4, 2009 00:18 |
|
White-Lightning posted:If I do it like this it will not get past You need to be a bit more clear about what you mean by "will not get past". Does the program just stop there? It sounds like there's a bug in your cs216program5 code.
|
# ? Dec 4, 2009 00:21 |
|
ShoulderDaemon posted:You need to be a bit more clear about what you mean by "will not get past". Does the program just stop there? It sounds like there's a bug in your cs216program5 code. sorry, this is a cgi, the source of the webpage has nothing in it after this first display of output. the cs216program5 runs fine, it will return the data exactly as i need it, which is _223315_Daniels_Tom_April 02, 1990_2E_DNA1.data_ I can run it from the command line and it returns _223315_Daniels_Tom_April 02, 1990_2E_DNA1.data_
|
# ? Dec 4, 2009 00:23 |
|
White-Lightning posted:sorry, this is a cgi, the source of the webpage has nothing in it after this first display of output. the cs216program5 runs fine, it will return the data exactly as i need it, which is _223315_Daniels_Tom_April 02, 1990_2E_DNA1.data_ You can run CGI's from the command line as well as long as you're using CGI.pm to handle getting query parameters. You should either do that or check your server's error logs for more information, because there are any number of things that could be going wrong, and you've got basically nothing to go on. Also, note that the CWD of your CGI may not be the directory it resides in when executed by the webserver, so ./ may not be the correct path to the cs216program5 program.
|
# ? Dec 4, 2009 00:28 |
|
Mario Incandenza posted:Don't you just love it when a reference is accidentally numified and passed through to your merchant account as a $166m charge against a dummy card number and the bank locks down your payment gateway as a result? Haha. The catalyst app that I wrote for CC processing successfully charged a card for 20k recently. I guess they actually owed us that much, but we're supposed to get paid by money order for anything that large. Oops, guess I should add an upper limit :o
|
# ? Dec 4, 2009 00:43 |
|
I'm new to coding and was asked to code a script that parses a text file A, and outputs text file B. Text file B contains every line from text file A that started withe number one. I got the READDATA part, the entering argument part, and increase line incrementally by 1 part, but I can't figure out how to actually tell it to say "OK output this line only if it starts with a line". Any help would be appreciated. edit: code:
thehandtruck fucked around with this message at 19:03 on Dec 20, 2009 |
# ? Dec 20, 2009 19:00 |
|
|
# ? May 21, 2024 20:18 |
|
You on unix? if so this would workcode:
Aaand if you're not on unix doing the file io in perl isn't too hard code:
The 'use warnings' and 'use strict' pragmas are a habit to get into Now, they will catch so many stupid errors for you it's not even funny Blotto Skorzany fucked around with this message at 19:25 on Dec 20, 2009 |
# ? Dec 20, 2009 19:17 |