Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: file header change

by tmharish (Friar)
on Feb 05, 2013 at 09:52 UTC ( #1017097=note: print w/ replies, xml ) Need Help??


in reply to file header change

Where exactly are you stuck?

Did you manage to open the file

Can you print the contents of the file from your script

Assuming that you can, all you need is:

if( $line =~ />contig_(\d+)\s/ ) { print ">$1\n"; } else { print "$lin +e\n"; }


Comment on Re: file header change
Download Code
Re^2: file header change
by utpalmtbi (Acolyte) on Feb 05, 2013 at 10:30 UTC
    thanks tmharish.. i used the following, but its not working.. :
    use strict; use warnings; sub read_file { my( $filename ) = <STDIN>; my @lines; sub read_file { my( $filename ) = <STDIN>; my @lines; open( FILE, "< $filename" ) or die "Can't open $filename : $!" +; { if( @line =~ />contig_(\d+)\s/ ) { print ">$1\n"; } else { print "$line\n"; } }

    :-(

      , but its not working..

      I am not surprised.

      Why do you have the same function defined twice? The second time inside the first??

      Create two functions, one to get the file name and the other to read the file, modify the contents and print it

      CALL the functions

      And finally try to run your code and get rid of the syntax errors.

        got it.. thanks tmharish for ur cooperation..

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2014-12-22 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (130 votes), past polls