Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Shorten the headers of a file and remove empty lines using perl

by Cristoforo (Deacon)
on Jun 13, 2013 at 23:43 UTC ( #1038865=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Shorten the headers of a file and remove empty lines using perl
in thread Shorten the headers of a file and remove empty lines using perl

Ah, I didn't see your problem clearly. First, you should use strict; as well as use warnings;, which you did, in the header of your program. Then, you have to assign the name of your file to $genome.

my $genome = 'whateverthename';

(You must assign a name to your output file also)


Comment on Re^3: Shorten the headers of a file and remove empty lines using perl
Select or Download Code
Replies are listed 'Best First'.
Re^4: Shorten the headers of a file and remove empty lines using perl
by Anonymous Monk on Jun 14, 2013 at 01:27 UTC
    It works very well. Although I do not quite understand all the script yet, I will work on that. Thank all people here for your help!

      I skipped the bit where you set up the names of input file and output file. But generally speaking, you should always always 'use strict;' and 'use warnings;'. They really are the very best ways to stop a program doing anything weird.

      And as mentioned above- a while look is better than a foreach if you're processing a large file. (Makes little odds for a small file, but it's good form).

      Perl is very clever - it understand context. <$input_fh> says 'read from $input_fh' but if you do:

      my $line = <$input_fh>;

      it simply reads the next line. Where if you do

      my @whole_file = <$input_fh>;

      It will read the whole file into that array - which is in effect what my first snippet does. It doesn't make much difference if you're working with a small file, but the difference will become very important with a 500MB file.

      I'd strongly suggest taking time to understand what each line is doing - code that someone on the internet gave you is never trustworthy. (Although on Perlmonks, usually true evil will get stomped upon)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2015-07-08 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls