|
syphon posted:I keep trying to get into Catalyst or Plack You say this like Catalyst and Plack are conceptually close. They are not. Plack is a web server interface. You have a web application that talks Plack, and it can run on any server that understands Plack. It makes deploying web applications dead easy. This is similar to (and named after) Rack in the ruby world. Catalyst is a web framework. It gives you tools to write web applications. (So does CGI.pm, albeit tools that were crummy by even 1998 standards.) Catalyst talks Plack, so you can deploy it on any server that understands it. Stuck in a CGI-only environment? Plack::Handler::CGI to the rescue. Yes, even you can run complex web applications with the breathtaking speed afforded by CGI.
|
# ? Jan 19, 2012 05:35 |
|
|
# ? May 21, 2024 14:51 |
|
I like a lot of control and don't really trust stuff like DBIx::Class. What's the best web framework to use that lets me write my own SQL, account management, etc?
|
# ? Jan 19, 2012 06:02 |
|
I like Mojolicious, or Dancer for smaller stuff. Catalyst is pretty solid too. I actually don't know of many web frameworks that force you to use a specific type of ORM or session cache or template engine etc. Maybe jifty?
|
# ? Jan 19, 2012 09:34 |
|
Ninja Rope posted:I like a lot of control and don't really trust stuff like DBIx::Class. What's the best web framework to use that lets me write my own SQL, account management, etc? Edit: Mojolicious isn't a very good choice when you want control over your tools, since a bunch of things, like Mojo::JSON are hard-coded in it. Mithaldu fucked around with this message at 10:15 on Jan 19, 2012 |
# ? Jan 19, 2012 09:48 |
|
Ninja Rope posted:Or CGI::Stateless, CGI::Session, CGI::Cookie, HTML::Template, and AnyEvent::FCGI? Woah, I've used AnyEvent quite a few times in the past. I didn't know there was an AnyEvent::FCGI
|
# ? Jan 19, 2012 10:23 |
|
I'm now looking into Catalyst, which apparently has a DBI submodule.Iif it works any better than the standard DBI module, it might be useful. Digging for tutorials now.
|
# ? Jan 19, 2012 15:20 |
|
I have a requirement to replace characters in a given string so that it only contains A-Za-z0-9.-_ Can anyone point me in the right direction? Thanks in advance! code:
|
# ? Jan 20, 2012 17:07 |
|
pre:$name =~ s/[^A-Za-z0-9.-_]/-/g
|
# ? Jan 20, 2012 17:18 |
|
Wow, thank you. I thought it was going to be much more complicated (substrings, looping, etc.). I switch between too many languages (the worst, of which, is XSLT). Thanks!
|
# ? Jan 20, 2012 17:29 |
|
code:
code:
I'm just consoling myself with the fact that I've only been doing it for a week or two. RICHUNCLEPENNYBAGS fucked around with this message at 10:57 on Jan 22, 2012 |
# ? Jan 22, 2012 10:54 |
|
How do you make a module save configuration data? I have a module that ideally should read a data dictionary once, save it, and use it from then on out. Right now I'm using File::Save::Home, but I don't know if that's the best way to go about it. What are my options here? When I search for modules and configuration files, I get nothing but results about modules that can read configuration files, which is not what I want - I want to be able to write configuration data to be read the next time the module is used.
|
# ? Jan 23, 2012 19:58 |
|
Sizzler Manager posted:How do you make a module save configuration data? I have a module that ideally should read a data dictionary once, save it, and use it from then on out. Right now I'm using File::Save::Home, but I don't know if that's the best way to go about it. What are my options here? When I search for modules and configuration files, I get nothing but results about modules that can read configuration files, which is not what I want - I want to be able to write configuration data to be read the next time the module is used. If you like XML, you can use XML::Simple.
|
# ? Jan 23, 2012 20:08 |
|
prefect posted:If you like XML, you can use XML::Simple.
|
# ? Jan 23, 2012 20:29 |
|
Sizzler Manager posted:Actually, what I'm getting confused about is more basic - I can't figure out how to get the module to save a file in a predictable place without giving it a hardcoded path. This is probably a pretty stupid question, but that's where my issue is - how do I get the module to save its own data in a directory relative to the module's location? You can use Findbin for this. Also: gently caress XML and especially XML::Simple. You don't want it for this task at all. Use either YAML or JSON for serialization into readable formats.
|
# ? Jan 23, 2012 21:35 |
|
Acme::State is exactly the solution to everyone's problems.
|
# ? Jan 24, 2012 03:57 |
|
File::HomeDir (does this still pull in a ton of awful Carbon modules) + serializer of choice?
|
# ? Jan 24, 2012 05:23 |
|
File::HomeDir uses Mac::SystemDirectory now, which doesn't depend on any non-core modules. If you actually want to use a directory relative to the current module (and not the currently running script or home directory) __FILE__ will give you the path to the currently compiling file. You almost certainly want to run it through File::Spec->rel2abs outside any subs though, to protect against possible directory changes. File::ShareDir is probably a better approach for module or dist configuration data.
|
# ? Jan 25, 2012 01:26 |
|
Haarg posted:File::HomeDir uses Mac::SystemDirectory now, which doesn't depend on any non-core modules.
|
# ? Jan 25, 2012 15:47 |
|
quote:DBIx::Class::ResultSet::count(): DBI Connection failed: DBI connect('rivals','root',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/local/share/perl/5.10.1/DBIx/Class/Storage/DBI.pm line 1248 at starter_ref_add.pl line 4 So i'm assuming this is a Perl problem and not mysql. I've reinstalled mysql anyway, and also all the Perl DB modules, and am still at square 1. What should I try next? uG fucked around with this message at 22:11 on Mar 8, 2012 |
# ? Mar 8, 2012 19:33 |
|
If you're trying to connect to localhost, try connecting to 127.0.0.1 instead. MySQL has a stupid thing where it forces socket connection when it sees localhost, even if you asked for a port.
|
# ? Mar 8, 2012 21:29 |
|
Mithaldu posted:If you're trying to connect to localhost, try connecting to 127.0.0.1 instead. MySQL has a stupid thing where it forces socket connection when it sees localhost, even if you asked for a port. uG fucked around with this message at 22:31 on Mar 8, 2012 |
# ? Mar 8, 2012 22:11 |
|
uG posted:Yea i've tried that, still no go. If I use plain DBI I can access the socket. So it must be DBIx::Class related (and also with count)... I just don't see how it could have happened on its own In that case i'd suggest getting on irc.perl.org and bothering ribasushi.
|
# ? Mar 8, 2012 23:22 |
|
Or strace and look for calls to open/connect/whatever unix sockets use?
|
# ? Mar 8, 2012 23:27 |
|
I don't do much coding, so pardon the potential in this post. I'm parsing a text file. One column in my data always contains a positive integer, but not all of them are encoded as, say, 1080; a few are encoded as " 1,080 ". (This is an actual example from my input file, including the pair of double quotes.) No problem, right? I'll just strip everything that's not a digit, like so: code:
Why is this happening, and what am I doing wrong?
|
# ? Apr 17, 2012 02:36 |
|
That line works for me:code:
|
# ? Apr 17, 2012 02:41 |
|
Why not use \d+ instead? Not sure it'll help whatever problem you're having, but seems simpler.
|
# ? Apr 17, 2012 06:38 |
|
Het posted:That line works for me: Using exactly this code in a loop that reads in all data from the text file: code:
syphon posted:Why not use \d+ instead? Not sure it'll help whatever problem you're having, but seems simpler. This doesn't work either. For the record, the statement currently right above it is: code:
Another thing that I didn't realize before might be a problem is that I'm running an ancient version of Perl. It's v5.8.7, running on Windows XP, if that makes any difference. I didn't realize I was that behind the times! I'll try an update and see if that makes this mysterious problem vanish, and edit in results. edit: Upgrading to v5.14.2, build 1402, Windows XP for x86, does not fix the problem. I used the binary from ActiveState, if that makes any difference. Boldor fucked around with this message at 05:41 on Apr 18, 2012 |
# ? Apr 18, 2012 05:26 |
|
Boldor posted:Using exactly this code in a loop that reads in all data from the text file: code:
If that's the problem I have 4 words for you: Always use strict goddammit!!!
|
# ? Apr 18, 2012 05:41 |
|
Het posted:Oh man I hope this isn't it but notice that in: Yes, that's it. Dammit I knew it was something stupid like that.
|
# ? Apr 18, 2012 05:42 |
|
Het posted:If that's the problem I have 4 words for you: Always use strict goddammit!!! Seriously, if anyone asks a question without using strict and warnings in their code, they're wasting our (moderately well-paid) time.
|
# ? Apr 18, 2012 11:29 |
|
Anaconda Rifle posted:Seriously, if anyone asks a question without using strict and warnings in their code, they're wasting our (moderately well-paid) time. I've run into that kind of problem using strict (variable doesn't have anything like the expected return value), but it usually ends up being because I accidentally localized a variable when I was moving things around.
|
# ? Apr 18, 2012 12:41 |
|
What's the deal with the "universal->import is deprecated" warning? I've searched around for this, and it's apparently a practice that you're not supposed to use which was deprecated in 5.12, but what is it and why were people using it? There's a module I'm interested in using or modifying for my own purposes (Brick by brian d foy), but among other things, trying to install it gives me a bunch of deprecation warnings for whatever that is.
|
# ? May 1, 2012 12:22 |
|
Sizzler Manager posted:What's the deal with the "universal->import is deprecated" warning? I've searched around for this, and it's apparently a practice that you're not supposed to use which was deprecated in 5.12, but what is it and why were people using it? There's a module I'm interested in using or modifying for my own purposes (Brick by brian d foy), but among other things, trying to install it gives me a bunch of deprecation warnings for whatever that is. http://perldoc.perl.org/UNIVERSAL.html#EXPORTS, most likely.
|
# ? May 1, 2012 13:58 |
|
Anaconda Rifle posted:Seriously, if anyone asks a question without using strict and warnings in their code, they're wasting our (moderately well-paid) time. In case it's not common knowledge, "Use Modern::Perl" will use Strict, Warnings and specific 5.10+ features. Shortcut to enable all of these.
|
# ? May 9, 2012 06:52 |
|
I'm currently (re)learning Perl and am writing my first proper program. This is more of a philosophical question than a practical question, I'm just wondering if there's any way I can make the method I'm using more elegant and/or efficient. What I have is a file with two reasonably large (~12k) lists of numbers in them (properties of a chemical). I'm characterising the chemical by making a 2d histogram - ie if the two lists read 1 1 1 and 4 4 6 I'll have 2 at (1,4) and 1 at (1,6). At the moment I'm reading the file into two arrays of argument 0-whatever and for each value of the argument adding 1 to the respective histogram array where the coordinate (form: xy) is the argument - so histogram[14] = 2 using the earlier example. Most of the end result of the histogram is going to be white space, so I can't just print the whole thing out. So I make it print out in the format coordinate: value iff the value stored in the array is nonzero. There's a maximum number of coordinates of about 36000, so brute forcing it won't be too inefficient, If you'd like to see my code I can do that (it's on a lab computer that I don't want to log into SA on ), but in terms of writing the code I'd like to make my own mistakes (for now!) and I'm more asking in case there's a more elegant way of doing things that I've missed.
|
# ? May 14, 2012 11:58 |
|
MrL_JaKiri posted:What I have is a file with two reasonably large (~12k) lists of numbers in them (properties of a chemical). I'm characterising the chemical by making a 2d histogram - ie if the two lists read 1 1 1 and 4 4 6 I'll have 2 at (1,4) and 1 at (1,6). Are you sure histogram[X] is unique? What happens on (21, 1) versus (2, 11)? There's nothing terribly wrong with your methodology other than that collision possibility. I'd probably have implemented it as a hash of hashes, which would save you a bit of memory and cost you a bit more CPU when you read out the histogram, but ultimately it's not that important for this size data set on modern hardware.
|
# ? May 14, 2012 15:42 |
|
baquerd posted:Are you sure histogram[X] is unique? What happens on (21, 1) versus (2, 11)? Good point; All the information is to 3sf so I'll explicitly make the combination include leading zeros - so 21001 vs 2011 (leading zeroes in x implicit for the argument, explicit when I print the argument to file so 021001 vs 002011). Cheers
|
# ? May 14, 2012 16:07 |
|
Another dumb question, but I seem to remember there being a way to make programs be more sequential; ie consider a file with A, B, C in it. What I want is to be able to append, say, D to the file (so that on the disk it says A, B, C, D) and then later in the same program print the file such that it displays A, B, C, D rather than the value of the file (A, B, C) that was the case when the program was created. [edit] Thanks to both of you MrL_JaKiri fucked around with this message at 16:19 on May 16, 2012 |
# ? May 15, 2012 23:10 |
|
I don't understand what you're asking. After you open a file you can append to it by seek()'ing to the end before writing. If you want to re-read that file from the start with the data you appended, seek() to the beginning before reading.
|
# ? May 16, 2012 07:51 |
|
|
# ? May 21, 2024 14:51 |
|
MrL_JaKiri posted:Another dumb question, but I seem to remember there being a way to make programs be more sequential; code:
|
# ? May 16, 2012 11:38 |