Hey Everyone,
I wrote a script which was originally a one off thing, but now more people have expressed interest in using it and I would like to make it a little more robust. I would like to make my script handle all types of new line characters LF,CR, and CRLF so that the users can remain in their blissfully unaware state about such things ;) Here are the file loading subs:
sub load_parents
{
my ($parent_index) = @_;
my %parents;
open (FH, "< $parent_index") or die "could not open file $parent_i
+ndex for reading:$!";
while (my $line = <FH>) {
chomp($line);
my ($index, $parent) = split(/\t/, $line);
$parents{$index} = $parent;
}
return \%parents;
}
sub load_primers
{
my ($primer_index) = @_;
my %primers;
open (FH, "< $primer_index") or die "could not open file $primer_i
+ndex for reading:$!";
while (my $line = <FH>) {
chomp($line);
my ($index, $primer) = split(/\t/, $line);
$primers{$index} = $primer;
}
return \%primers;
}
I woud appreciate any advice on what I could do to hanle the different new line characters, or if you see a blatent flaw in my logic don't be affraid to point that out either.
Thanks, Mav
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.