Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Ninja Rope
Oct 22, 2005

Wee.
I'm not sure if you're basing your question off of what satest4 said, but 'eq' is not so slow as to make it unwise to use. Use eq and == where appropriate, ie, eq for strings and == for integers, and don't worry about the performance implications of either.

Adbot
ADBOT LOVES YOU

Ninja Rope
Oct 22, 2005

Wee.

Erasmus Darwin posted:

Close. You want a dollar-sign in front of test, not a percent. So it's:
$false_thing=$test{little_hash}{foo};

Older versions of ActivePerl were buggy when using this syntax (referencing nested hashes without the arrow operator). Because of that, and the inconsistent (to new developers) quoting rules for hash keys, I find it's better to write $false_thing = $test{'little_hash'}->{'foo'}, though it may never matter for you.

Ninja Rope
Oct 22, 2005

Wee.

TheHeadSage posted:

what issues would I run into?

Locking all tables from writes every 15 minutes to insure consistency? Are you using innodb with transactions?

Edit: Er, sorry, I'm assuming you're using mysql, is that correct?

Ninja Rope fucked around with this message at 07:02 on Sep 21, 2009

Ninja Rope
Oct 22, 2005

Wee.
I don't recall if this was covered already, but can someone give me a rundown of the various web frameworks? CGI::Application/Titanium, Maypole, Catalyst, Jifty, etc?

I've been putting together a simple site for a non-work project and I figured it would be a good excuse to learn a framework but it seemed like none of them integrated well with fastcgi, and the ones that did would take too long to learn. They're all probably too large for something simple like what I'm working on, but I'd still like recommendations for what to look at for the next time a big project comes along.

Ninja Rope
Oct 22, 2005

Wee.
My biggest problem with the logo is this:

perl6.org posted:

Hi, my name is Camelia. I'm the spokesbug for Perl 6, the spunky little sister of Perl 5.

I think personifying a logo and having it "talk" to users is too childish, perhaps even creepy. Programming languages don't need to be playful or fun and I think it gives off the wrong impression. Text like the above impedes access to the information users actually want by making them filter through unrelated chatter from the "spokesbug". It also makes promoting perl6 as a serious language alternative harder when the logo looks like something targeted towards children and the websites feature text "written" in first person by a butterfly. A programming language doesn't need a logo, but if it has one it should be unintrusive and only really used to help users identify information related to that language. I don't need to play with it.

Ninja Rope
Oct 22, 2005

Wee.
You may want to try replacing calls to sysread with recv and see if that makes a difference.

Ninja Rope
Oct 22, 2005

Wee.

mister_gosh posted:

Are there any considerations to make with this script on W7? It works fine on my XP machine but does not work in W7 on a particular machine. The permissions appear to be open for the user (I believe they are an admin, in fact):

code:
open(LOG, ">C:/helloworld.txt");
print LOG "hello world";
close LOG;

Isn't that just Windows 7 keeping the user from writing to the root of the drive? It's not enough to be "an admin", you have to run the interpreter as "an admin", ie, via right-clicking it and saying "Run as administrator".

Alternately, make that open() || die $! so you at least get an error message?

Ninja Rope
Oct 22, 2005

Wee.
There are also a million date manipulating modules you could use. Date::Time, Date::Manip, and Date::Calc come to mind.

Ninja Rope
Oct 22, 2005

Wee.
The time it takes new to return is going to depend on a lot of things, including how the remote end responds (or doesn't respond) to closed or blocked ports and the number of retries configured. TCP is guaranteed to return eventually from connect(), but the amount of time depends on a lot of things.

Ninja Rope
Oct 22, 2005

Wee.
Can you expand on "don't pre-declare variables"? Ever? Or just in this instance?

For variables used a bunch of times throughout a function, I find it better to pre-declare them.

Ninja Rope
Oct 22, 2005

Wee.

OriginalPseudonym posted:

You can, but it's finicky.

Or you can try sending a Content-Disposition header.

Ninja Rope
Oct 22, 2005

Wee.

syphon posted:

I'm sure people are gonna hate me for saying this... but I've used CGI + HTML::Template + CGI::Ajax for smaller webapps with great success before. I keep trying to get into Catalyst or Plack (this was before I knew about Dancer) and the added overhead just seemed tremendous for what I was trying to do.

Or CGI::Stateless, CGI::Session, CGI::Cookie, HTML::Template, and AnyEvent::FCGI? :whatup:

Ninja Rope
Oct 22, 2005

Wee.
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?

Ninja Rope
Oct 22, 2005

Wee.
Or strace and look for calls to open/connect/whatever unix sockets use?

Ninja Rope
Oct 22, 2005

Wee.
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.

Ninja Rope
Oct 22, 2005

Wee.
Lots of resumes, all terrible.

Ninja Rope
Oct 22, 2005

Wee.
I've started asking for code examples. Everyone who makes it to round 2 gets an example spec and is expected to write a unix daemon that implements that spec. Doesn't matter what language, I figure a good programmer can learn Perl faster than we can turn a bad programmer into a good one.

Similarly, if anyone wants a Perl job in the Bay Area. I think we re-locate, but I'm not sure.

Ninja Rope
Oct 22, 2005

Wee.

GTGastby posted:

I'm trying to kill a particular process (foo) from within a perl script (bar).

I'm trying the command:

code:
system("kill -9 `ps -ef | grep foo | awk '{ print $2 }'`");
The unix bit seems to run fine when I run it in the shell, but when I put it in my perl script, the script shuts down / kills itself when it hits that line. Although it does kill foo in the process - I'd like the perl script to keep running.

Any idea what is going wrong?

code:
ps -ef | grep 
The above bit is not picking up my perl script, for those wondering.

It could be the $2 being interpolated due to the double quotes, but you should probably re-write it to use something like Proc::ProcessTable and kill().

Ninja Rope
Oct 22, 2005

Wee.

uG posted:

I'm sure there is a reason its not a good idea, but why can't I use system/exec calls to run code inside a thread (to avoid running out of memory)?

Threads share address space, so any memory they allocate is counted against you too. But from the way you formed that question I'm guessing that if you give a better description of what you're trying to do we can come up with a better solution.

Ninja Rope
Oct 22, 2005

Wee.
I like The Regex Coach but the newer versions are Windows only. :(

Edit: It's free.

Ninja Rope
Oct 22, 2005

Wee.

Roseo posted:

You can open a file with a scalar filehandle, which gives it implicit scope. You don't bneed to close it, for example, it'll do so when it goes out of scope. Though you are using three arg open, that's good.

Doesn't it get closed when Perl GC's the variable? Which doesn't necessarily have to happen right as it goes out of scope, it could happen later (or possibly not until the program exits?). In practice it will close the filehandle pretty much right after it goes out of scope but I don't believe that's a guarantee. If you need the handle closed it's best to close it explicitly.

Ninja Rope
Oct 22, 2005

Wee.

Haarg posted:

variables are guaranteed to be cleaned up immediately when they go out of scope

Not that I don't believe you, but can you show me where it's documented? I'd like to know more.

Ninja Rope
Oct 22, 2005

Wee.
In addition to that, many modules are pure perl.

Adbot
ADBOT LOVES YOU

Ninja Rope
Oct 22, 2005

Wee.

Pollyanna posted:

:wtc: Okay, so the input parameter is not getting passed for some reason. Is it because of the way I wrote it? If I try print $cgi->textarea({-style=>"height: 200px; width: 300px;", -name=>"input"});...

code:
$VAR1 = [ 'input', 'submit_sequence' ]; 
:woop: There we go! Looks like Perl just shits its pants over the braces.

The (curly) braces make a big difference. The braces indicate that a new hash table should be created containing the keys/values inside the braces and than that hash table should be passed to the textarea() method. The text area method doesn't want a hash table, so passing it one causes things not to work. CGI is a little confusing about what methods want hash tables and what don't, so it helps to check the perldoc often.

  • Locked thread