|
TiMBuS posted:URL rewriting has nothing to do with separating 'run modes' into multiple files. FFS, who pissed in your cornflakes? You seemed to be asking how to get a restfull interface out of a single cgi app without throwing files all over the place, if that's not what you were after then I was answering the wrong question. However if it were, url rewriting would be one way to do it. The wrong way. Allow me to quote from the mod_rewrite docs mod_rewrite docs posted:The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail.'' I hope this puts things into perspective.
|
# ? Apr 11, 2008 19:19 |
|
|
# ? May 21, 2024 18:30 |
|
Zombywuf posted:FFS, who pissed in your cornflakes? So you sir. You pissed in my cornflakes. Zombywuf posted:..Url rewriting would be one way to do it. It's clean, it's useful, a bunch of frameworks like ruby on rails and applications like wordpress use it, and I like it. Furthermore it's only a 4-line addition to the .htaccess: code:
PS: Even with all that to back me up, I'm not even using rewrite any more. I found it sufficient to just parse the PATH_INFO environment variable for almost the same look, which makes it more portable.
|
# ? Apr 12, 2008 01:00 |
This is getting a bit outside the scope of Perl... but hope you guys will still help me. TiMBuS posted:mod_rewrite stuff I want to access this URL: http://hostname/appname/app.cgi?param=foo Via this URL: http://hostname/appname/foo Looking at the example you provided, it seemed like it would be pretty straightforward, but I'm obviously screwing something up, as it's not working. This is what i added... code:
syphon^2 fucked around with this message at 18:40 on Apr 14, 2008 |
|
# ? Apr 14, 2008 18:08 |
|
Any recommendations/experience with ORM packages? I'm hopefully going to be involved in a project soon and I would like to introduce people to business level objects and what not... So I need an ORM layer. But I don't know of any. I've used one before, so I know what to expect, but it was shop-specific/proprietary. Class::DBI?
|
# ? Apr 16, 2008 22:18 |
|
I've found CDBI to be the slowest of the three major ORM packages (Class::DBI, DBIx::Class, Rose::DB::Object), and this benchmark seems to support that. RDBO may be the fastest but in the end I decided to stick with DBIC since it's the one most often used in conjunction with Catalyst and all the documentation reflects that, plus it was closer in usage to CDBI which I had previous experience with.
Mario Incandenza fucked around with this message at 00:03 on Apr 17, 2008 |
# ? Apr 17, 2008 00:01 |
|
I'll second SpeedFrog's recommendation of DBIx::Class. I started with Class:: DBI but got frustrated with the lack of features / extensibility / plugins available. I've heard Rose:: DB is a screamer, but haven't gotten around to taking a look at it. DBIx::Class has many hooks and a great selection of third party plugins for profiling & debugging & adding new features. It's also got great support for the basics of database / object relationships (belongs_to, may have, has_one, has_many, many_to_many).
|
# ? Apr 17, 2008 15:37 |
|
syphon^2 posted:This is getting a bit outside the scope of Perl... but hope you guys will still help me. I'm pretty sure this is your problem: code:
If you want a conditional rewrite, then you should use RewriteCond. (I didn't use RewriteCond for /static because I didn't know how when I wrote the htaccess file a year and a half ago. I should fix it.) Turn your first rewrite into this: code:
code:
I also really suggest you add [QSA] to your last line, which will allow you to do stuff like http://hostname/appname/foo/?otherparam=morefoo which will conveniently translate out to http://hostname/appname/app.cgi?param=foo&otherparam=otherfoo
|
# ? Apr 17, 2008 23:42 |
|
I'm having a hell of a time trying to figure out why when I try to open a file, it sets the filehandle to the name of the file and not the lines inside of the file.code:
|
# ? Apr 25, 2008 21:34 |
|
LightI3ulb posted:I'm having a hell of a time trying to figure out why when I try to open a file, it sets the filehandle to the name of the file and not the lines inside of the file. That looks wrong. You're passing in the name of the file by reference.. why? Also, readdir returns the filenames relative to the directory from which you're reading. So you have to prepend the directory's path to each file. You actually want something like: code:
|
# ? Apr 25, 2008 21:37 |
|
drat, that was it. Thanks. As to the by reference thing, I have no idea. That's the only way I could get it to work. If I tried anything else, the file wouldn't open.
|
# ? Apr 25, 2008 21:56 |
|
It's also generally preferable to use real scalars for file handles (open($fh, '<', '/etc/password');) as opposed to the all-caps style handles (but that wouldn't make a difference for what you're doing).
|
# ? Apr 25, 2008 22:19 |
|
Are scalar file handles superior to traditional ones in every way? I started out using the traditional ones and only recently started to use the scalar version, but I'm wondering if there's any reason, at all, to be using the old way. The scalar one has lexical scoping, which is nice, and I think the old way is globally (not?) scoped? The new one you could pass around like a scalar and the old one not at all?
|
# ? Apr 25, 2008 22:31 |
|
Triple Tech posted:Are scalar file handles superior to traditional ones in every way? I'd say so. Another big benefit is that they automatically close when the scalar is freed. Globals are freed (and thus, the filehandle automatically closed) only when the interpreter shuts down.
|
# ? Apr 25, 2008 23:01 |
|
...
maskenfreiheit fucked around with this message at 04:23 on Sep 29, 2010 |
# ? Apr 28, 2008 03:47 |
|
That program works fine for me:code:
|
# ? Apr 28, 2008 04:23 |
|
GregNorc posted:Any ideas how to fix this? I even looked in the appendix for the answer, and still no luck. For a start: turn on warnings and use strict; Avoid the use of $_, and be a little bit more explicit about what you're trying to do rather than relying on perl. code:
|
# ? Apr 28, 2008 11:06 |
|
GregNorc posted:
The code above works fine in OSX 10.4 for me. Also there's no reason to prefix sub names with &. fansipans fucked around with this message at 11:58 on Apr 28, 2008 |
# ? Apr 28, 2008 11:39 |
|
fansipans posted:Also there's no reason to prefix sub names with &. Actually, there is a difference... And it's a terrible one. And I never use it. But in this particular scenario and use, you are correct.
|
# ? Apr 28, 2008 14:58 |
|
Triple Tech posted:Actually, there is a difference... And it's a terrible one. And I never use it. But in this particular scenario and use, you are correct. code:
code:
Mario Incandenza fucked around with this message at 15:33 on Apr 28, 2008 |
# ? Apr 28, 2008 15:31 |
|
Triple Tech posted:Actually, there is a difference... And it's a terrible one. And I never use it. But in this particular scenario and use, you are correct. In case anyone was curious: using & means the function call ignores the function's prototype, and passes in a plain list. As Triple Tech mentioned, it's pretty terrible.
|
# ? Apr 28, 2008 19:30 |
|
It's also useful when you want to make sure the parser knows you want to reference a function, like when using constants as hash keys:code:
|
# ? Apr 29, 2008 08:36 |
|
Sartak posted:In case anyone was curious: using & means the function call ignores the function's prototype, and passes in a plain list. As Triple Tech mentioned, it's pretty terrible. Don't forget goto &subname - a magic goto useful mostly in AUTOLOAD subs, so you can replace the top frame of the call stack and cover your tracks. Ninja Rope posted:It's also useful when you want to make sure the parser knows you want to reference a function, like when using constants as hash keys: Don't really like constant.pm... the lack of (easy) interpolation and all the edge-cases requiring &s or ()s make the cure worse than the disease. Instead, why not: code:
Mario Incandenza fucked around with this message at 09:56 on Apr 29, 2008 |
# ? Apr 29, 2008 09:51 |
|
SpeedFrog posted:Don't really like constant.pm... the lack of (easy) interpolation and all the edge-cases requiring &s or ()s make the cure worse than the disease. Because that Readonly module is going to be really slow. The whole point of constant.pm is that the compiler will inline the data (because it is a sub) and creates no symbol table entry. It's more like a pre-processor constant the way C constants are. The syntax is retarded, I agree, but it's a very important module.
|
# ? Apr 29, 2008 15:40 |
|
genericadmin posted:Because that Readonly module is going to be really slow. The whole point of constant.pm is that the compiler will inline the data (because it is a sub) and creates no symbol table entry. It's more like a pre-processor constant the way C constants are. The syntax is retarded, I agree, but it's a very important module.
|
# ? Apr 29, 2008 16:15 |
|
I use constant.pm in most of my perl programs; though usually only to define TRUE and FALSE.
|
# ? May 2, 2008 00:11 |
Can anyone give an example of a Perl script (using Win32::OLE) which enumerates all websites installed in IIS (preferably either version 5 or 6) and just dumps the data out in some consumable format? I've found Win32::OLE and Win32::OLE::Enum, which seem like they'd do what I need. I'm not familiar with Win32::OLE or the IIS Metabase, so I don't even know how to parse the object for the data I need. I can find a few examples, but nothing that really does what I need. For example... this (scroll down a bit) manages to grab the default site, but then crashes my Perl interpreter! The code found here seems to work, but I have to provide it with a specific siteid to inspect (and I want to gather all sites, no matter their siteid). Any advice? EDIT: I'm muddling through it, but painfully slow. I guess what I'm asking for is a snippet of code or module or something that does what I need more gracefully. This code crashes Perl in certain scenarios (unknown yet) and I think won't work with IIS6. This is what I have so far code:
syphon^2 fucked around with this message at 17:51 on May 7, 2008 |
|
# ? May 7, 2008 17:22 |
|
I've got a very confusing problem.code:
code:
To further confuse matters, the calculation of $sfrma was copied from another script doing a slightly different task and things worked there without the extra commented line. Does anyone have any ideas what could be going wrong? edit: If I remove "$QT*" from the denominator of $sfrma, the calculation works. The constants are all defined like: code:
6174 fucked around with this message at 18:33 on May 7, 2008 |
# ? May 7, 2008 18:30 |
|
Looks like you're confusing the Perl parser. Try adding some whitespace, if nothing else, just for readability's sake.
|
# ? May 7, 2008 18:39 |
|
Zombywuf posted:Looks like you're confusing the Perl parser. Try adding some whitespace, if nothing else, just for readability's sake. I just tried maybe a dozen variations of adding whitespace at various locations (including whitespace around every operator) and the same error occurred. This being the source (the parser being confused) would also be confusing to me because the line worked just fine from the script I copied it from (which roughly takes the same input format and outputs yet another different format). Also for the record, these scripts weren't things I wrote initially, I just need to change a formula here and there.
|
# ? May 7, 2008 18:47 |
|
Try running your script through Deparse to see what's actually running. perl -MO=Deparse script.pl
|
# ? May 7, 2008 18:54 |
|
6174 posted:I just tried maybe a dozen variations of adding whitespace at various locations (including whitespace around every operator) and the same error occurred. The problem with the Perl parser is that certain parts of the syntax (regexes mostly) can sometimes only be interpreted by looking ahead in the code. Generally its / that confuse it, does line 75 contain any /s? Also, what's the error you're getting?
|
# ? May 7, 2008 18:58 |
|
Triple Tech posted:Try running your script through Deparse to see what's actually running. perl -MO=Deparse script.pl I don't know what to make of the output of this: code:
The $sfrma calculation is on line 75 as posted above, and starting at 142 is: code:
6174 fucked around with this message at 19:14 on May 7, 2008 |
# ? May 7, 2008 19:00 |
|
Maybe you have a runaway parsing error. Try insert an __END__ token at points where you feel all the code above the token is 100% correct. Then slowly slide the line downwards, including more and more lines. Use this, a combination of the syntax check (-c) and Deparse and you should be good.
|
# ? May 7, 2008 19:02 |
|
6174 posted:Also line 3 is "use Switch;" I suspect your problem lies there, Switch will be doing weird things to your syntax tree to add more syntax into Perl. It's a bit of a pain, but you're safer with elsif.
|
# ? May 7, 2008 19:07 |
|
Zombywuf posted:I suspect your problem lies there, Switch will be doing weird things to your syntax tree to add more syntax into Perl. It's a bit of a pain, but you're safer with elsif. I think this is it. I just converted the switch to a bunch of if/elsif and it now parses correctly and runs. Thanks for the help Zombywuf and Triple Tech.
|
# ? May 7, 2008 19:13 |
|
Switch is evil, and the problems it has with /'s in your code are fairly well documented. Good riddance.
|
# ? May 7, 2008 19:42 |
|
HELP! What the hell is going on with this? code:
LightI3ulb fucked around with this message at 13:58 on May 14, 2008 |
# ? May 14, 2008 13:42 |
|
LightI3ulb posted:HELP! Always, always, always include these two lines: code:
|
# ? May 14, 2008 13:53 |
|
fansipans posted:Always, always, always include these two lines: Fixed. Still clueless.
|
# ? May 14, 2008 13:59 |
|
|
# ? May 21, 2024 18:30 |
|
LightI3ulb posted:Fixed. Still clueless. What errors are you getting?
|
# ? May 14, 2008 14:00 |