Program
#!/usr/bin/perl -w
# This program shows how to store DNA and RNA into variables and then print them out.
# The RNA is first stored in the variable $RNA.
$RNA = 'AUGCU';
# The DNA is stored in the variable $DNA.
$DNA = 'AGTCT';
# Now it is time to print the DNA and RNA onto the screen
print "This is the RNA strand: \n";
print "$RNA \n";
print "This is the DNA strand : \n";
print "$DNA \n";
exit;
Program Output
This is the RNA strand:
AUGCU
This is the DNA strand:
AGTCT
Explanation for Program
Line #1 - #!/usr/bin/perl -w
This tells Unix that the program is a Perl program. All operating systems check this line for certain commands at the end of the line. For example, -w is at the end of this line. This command tells Perl that there should be warning reporting.
Line #2/Line #3/Line #5/Line #7 - Pseudocode
Pseudocode does not follow traditional synax. Pseudocode always begins with the pound sign (#). The pound sign alerts Perl to ignore that line of code. Pseudocode usually describes the function of the program.
Line #4 - $RNA = 'AUGCU';
The entire line in line #4 is a statement. Statements always end in a semicolon (;), which is the equivalence of the period in English. There are many types of statements according to the function of the program.
$RNA
$RNA is considered to be a variable. There are different types of variables you will experience in Perl. $RNA is a scalar variable. A scalar variable only holds one line of data. A variable can be any name beginning with the dollar sign ($) (ex. $Joe or $be_happy). Uppercase and lowercase letters and digits can be used. However, the first letter cannot be a digit. The underscore is used as spaces between words. It doesn't matter what name you assign a variable as long as it begins with a dollar sign. Most programers assign a variable name that is appropriate for the function of the program.
'AUGCU'
This part of line #2 is a string. A string is always surrounded by quotes.
Assignment in Line #4
The equal sign (=) is used to assign the string to a variable. The equal sign is referred to as an assignment variable. In line #4, 'AUGCU' is assigned to $RNA. This causes the sequence AUGCU to be stored in the $RNA variable. Assignment must always be in the "variable = 'string';" order.
Line #6 - $DNA = 'AGTCT';
Again, the whole line of this code is a statement. Notice that it ends in a semicolon. $DNA is the variable, and 'AGTCT' is the string. $DNA is assigned to 'AGTCT' through the equal sign (=).
Line #8 - print "This is the RNA strand: \n";
"This is the RNA strand: \n";
This is a string. All the strings before this have been designated by single quotes (' '). However, strings can also be designated by double quotes (" "), as shown above.
This is one of the many Perl commands. This command instructs Perl to print the string.
\n
This is called the newline. This tells Perl to start the next line.
Line #9 - print "$RNA \n";
This command tells the computer to print the variable $RNA.
"$RNA \n";
This string stores the variable $RNA. As you noticed, Perl printed AUGCU, not $RNA. This is because $RNA represents AUGCU, since AUGCU is assigned to $RNA, as explained earlier. The characters \n tell Perl to go to the next line, as shown above.
Line #10 - print "This is the DNA strand : \n";
This statement tells Perl to print whatever is stored in the variable $DNA, as shown above.
Line #11 - print "$DNA \n";
This statement tells Perl to print whatever is stored in variable $DNA, as shown above.
Line #12 - exit;
The exit command tells Perl to exit the program.
Resources
Tisdall, James. Beginning Perl for Bioinformatics. 1st ed. Sebastopol, California: O'Reilly Media, Inc., 2001. Print.
Published by Katie
Two Americans, Andrew Z. Fire and Craig C. Mello are Awarded Nobel Prize...Two American researchers that discovered a method of "switching off" genes were awarded this year's Nobel Prize in Medicine or Physiology.
An Introduction to Programming in PerlPerl is a versatile programming language created by Larry Wall in 1987. He designed this language to extract and manipulate text files. It has since grown into a rich programmin...- Multidimensional Arrays in Perl 5.0: A Boon to Bioperl (Part 1)Bioperl can now take advantage of Perl 5.0. Perl 5.0 now comes with the added advantatge of modules that can handle multidimensional arrays. Systems biologists and genenomicists can archive, retrieve , modify, update...
- ActivePerl SubroutinesIn this part of the series, I explain Perl functions, also called subroutines.
- The Writing Process: How to Write a NovelConcentration on the writing styles of six writers' from different writing genres, including technical writing, academic writing, and fiction writing. Comparisons are drawn from different writers' composition style a...
- Perl and Bioinformatics: First Perl Program Tutorial
- The Oversimplification of DNA and RNA
- Polymerization of DNA & RNA Building Blocks
- Functions of DNA
- DNA (Deoxyribonucleic Acid) is One of the Most Vital Molecules of a Living System
- Scientific Breakthroughs: The Use of DNA in Modern Science
- Making Sense of the Genetics of RNA Viruses



