Do you intend to use the other @fields
array elements in some way or the other? or are you only splitting in order to access the $field
to check whether it is Withdrwan or Public? in both cases, you can get a better edge if you filter your lines first and then do things with the elements that constitute each line, this way, you have obtained the interesting lines (the ones that has 'withdrwan') and reduced your data file to a somewhat manageable chunk... Here in the code posted below is a more direct approach where I read the file a line at a time, used a look-ahead regular expression to check for incidence of 'Withdrwan' -regardless of case- and then transferred that line to another new file that has the same header information as the source file with the objective of only filtering entries where 'Withdrawn' has appeared in that particular line...
my $path = "C:/Documents and Settings/aldaihi/Desktop/Monks";
open (my $fh, '<',"$path/genes.txt") or die ("could not open file $!\n
open (my $rfh,'>',"$path/results.txt") or die ("could not open file $!
my $firstLine = <$fh>;
print $rfh $firstLine;
#U can do things to the line in here
# split or rearrange ..
print $rfh $_,"\n";
a module like Text::Table
can give you control over how your data is placed in columns without breaking your head on spacing issues...
Excellence is an Endeavor of Persistence.
A Year-Old Monk :D .
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||