Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help with perl

2 views
Skip to first unread message

Vip

unread,
Jan 28, 2012, 8:14:29 AM1/28/12
to
I have this problem to solve but i don't know how!

Develop a Perl program that receives as argument on the command line
the name of a file in the working directory (containing one DNA
sequence in FASTA format) and prints the content of the file with the
whole sequence in uppercase character.
-It checks the number of arguments received on the command line and if
the number is not 1 it prints an error message and exits.

Can anyone tell me how to develop this fuctions with perl?

Jens Thoms Toerring

unread,
Jan 28, 2012, 9:04:44 AM1/28/12
to
Vip <fabioma...@gmail.com> wrote:
> I have this problem to solve but i don't know how!
>
> Develop a Perl program that receives as argument on the command line
> the name of a file in the working directory (containing one DNA
> sequence in FASTA format) and prints the content of the file with the
> whole sequence in uppercase character.
> -It checks the number of arguments received on the command line and if
> the number is not 1 it prints an error message and exits.

Homework? And what have you tried so far?

> Can anyone tell me how to develop this fuctions with perl?

- Check the number of elements in the command line arguments
array @ARGV, if it's not 1 print an error message and exit.
- Use the open() function to open the file using the first
element of the argument array.
- Read it in line by line (using the '<>' operator) and
- if it's a line with a DNA sequence use the uc() function to
convert all characters to upper case (read the specification
of the FASTA format to figure out how these lines are diffe-
rent from description lines - seems to be trivial)
- print out the line.
- Close the file using the close() function.

Regards, Jens
--
\ Jens Thoms Toerring ___ j...@toerring.de
\__________________________ http://toerring.de

Tad McClellan

unread,
Jan 28, 2012, 10:16:50 AM1/28/12
to
Vip <fabioma...@gmail.com> wrote:


> Subject: Re: help with perl


You are not requesting help with Perl.

You are requesting that someone else write your program for you.

Do your own work.

If you truly need help, then show what you tried, describe what it is
doing and what it should do instead.

You are not fooling anybody...



> I have this problem to solve but i don't know how!


If you show us what you have tried so far, we will help you fix it.


> Develop a Perl program that receives as argument on the command line


Read about @ARGV

perldoc perlvar


> the name of a file in the working directory (containing one DNA
> sequence in FASTA format) and prints the content of the file


Learn how to open a file:

perldoc -f open

Learn how to print to a file:

perldoc -f print

> with the
> whole sequence in uppercase character.


Learn about functions that manipulate case:

perldoc -f uc


> -It checks the number of arguments received on the command line and if
> the number is not 1 it prints an error message and exits.


perldoc perlintro

has a section named "Numeric comparison" in it...


> Can anyone tell me how to develop this fuctions with perl?


It will require that you learn a bit of Perl programming!


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.

Jürgen Exner

unread,
Jan 28, 2012, 10:25:26 AM1/28/12
to
Vip <fabioma...@gmail.com> wrote:
>Develop a Perl program that receives as argument on the command line

See "perldoc perlvar" and look for @ARGV

>the name of a file in the working directory (containing one DNA
>sequence in FASTA format) and prints

perldoc - f print

>the content of the file

perldoc -f readline

>with the
>whole sequence in uppercase character.

perldoc -f uc

>-It checks the number of arguments received on the command line

perldoc -f scalar

>and if
>the number is not 1

perldoc perlop

>it prints an error message

perldoc -f print

>and exits.

perldoc -f exit

>Can anyone tell me how to develop this fuctions with perl?

Typically you would use the editor of your choice to write the code,
save it to your hard drive, and test it. Repeat until it does what it is
supposed to do.

jue
0 new messages