Thanks for that. Found another solution (from a colleague) which I have managed to implement. I've just created a few constants and changed the offending line as follows:
% cat t.pl
#!/usr/bin/perl -w
use strict;
...
my $PIPE_STRING = q{| tail -n +2}; # starts from line 2 of input
my $EMPTY_STRING = q{};
for my $chromosome ( sort { $a <=> $b } keys %chromosome_arms ) {
if ( scalar @{ $chromosome_arms{$chromosome} } >= 2 ) {
...
# a long running process (written in C++)
my $format = qq{ask_bigdb [options] %s >> $filename\n};
# generate the command
my $command = -e $filename # if file exists
? sprintf $format, $PIPE_STRING # use the tail pipe
: sprintf $format, $EMPTY_STRING; # use the empty string
# run the command here
print $command;
...
}
}
Yes I do need a redo there. Otherwise I would not get the second arm of my chromosomes. And this solution also does not require me holding much in memory. (At least I think not!)
Thanks again.
Smoothie, smoothie, hundre prosent naturlig!
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.