in reply to When to use modules?

Your thread title is slightly misleading. You say "To import or not to import", which made me think of modules and namespaces. Anyway...

Writing functions (and reusing code) and using modules is a basic tenet of good programming practice. Good programming has never been about keeping code long or short -- it's about what is the most flexible, safe, or feature rich -- balancing requirements.

The only time to 'inline' something would be when the function call was expensive (to save CPU load or equivalent), and here running time is not a major concern. If you were doing math, this might be different.

Of course, quick and dirty scripts are allowed to have their way in many occasions, but you incur risks if they grow to be something important, so it all matters what your approach is.

If you are trying to write 'good' code though, 'good' and 'short' are orthogonal. Often good can be short, but short is not always good. Good is usually clean, neat, and non-kludgy however. If you find a lot of error checking code making your program harder to read, move it to a function so you can keep your code clean -- but don't remove that code just because it makes the code shorter. In the case of your CGI example, I really don't find that syntax ugly at all, though I usually format my code so the dashes and arrows line up, at minimum. It makes me feel good:

my $cookie = $q->cookie( -name => "cart_id", -value => 12345, -domain => ".oreilly.com", -expires => "+1y", -path => "/cgi", -secure => 1 ); print "Set-Cookie: $cookie\n";

Silly, yes, but it makes that long code block seem fun and awe-inspiring. Ok, maybe not, but at least it's more readable -- especially when you want to start putting dollar signs in there.