One of the absolutely most offensive things I see wrt Perl is
the practice of calling a Perl script from a Perl script.
Why? Other than just bad taste, you are unnecessarily burdening the operating system with the overhead of creating an additional
perl interpreter, invoking all book keeping required for spawning and tracking child processes and memory. Oh, but it's just one extra process, you say! Well you keep doing that kind of thing and your CGI script grows in popularity and size - suddenly your server load is about 8,000 times what it should be. Do not laugh, I have seen it happen and continue to happen.
Turn
loadCSV.pl into a modulino - it can be done in very few lines, even if it's a monolitic Perl script from 1974.
End result in your caller (not the best practice but will save you an OS process fork:
use FindBin ($Bin);
require qq{$Bin/relative/../path/to/loadCSV.pl};
my $out = your::modulino->run( (qw/-L -Q/) );
print $out;
There are a million places to find informatin on modulinos, it's pretty much as simple as:
package your::modulino;
use strict;
use warnings;
# Note: I know this is awful but it's better than what OP is doing now
print __PACKAGE__->run(\@ARVG) if not caller;
sub run {
my $self = shift;
local @ARGV = @_;
# shove nearly all loadCVS.pl in here, getopt and all with ONE excep
+tion
# ...
# convert all of your "print" statements such they create the string
+ you
# were going to print, then:
return $formerly_printed_stuff;
}
1;
The above is dirty, but better what you're doing. And it provides the basis for really creating a well done modulino. Or better yet, an actual Perl module where the CLI version becomes a 3 line script calling the dern module you just peared off.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.