Difference between revisions of "Introductory Perl"

From irefindex
(Created page with "This introduction to Perl is taught as part of MBV-INF4410/9410. http://bioinformatics.uio.no/wiki/Bioinformatics_course Slides for the "Introduction to Perl" lectures: * [[Im…")
 
(Added some command prompt and notepad notes.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
This introduction to Perl is taught as part of MBV-INF4410/9410.
+
This introduction to Perl is taught as part of [[Bioinformatics_course|MBV-INF4410/9410]] and [http://www.uio.no/studier/emner/matnat/molbio/MBV3070/ MBV3070].
 
 
http://bioinformatics.uio.no/wiki/Bioinformatics_course
 
  
 
Slides for the "Introduction to Perl" lectures:
 
Slides for the "Introduction to Perl" lectures:
Line 7: Line 5:
 
* [[Image:Lecture_1_-_What_Perl_can_do.ppt]]
 
* [[Image:Lecture_1_-_What_Perl_can_do.ppt]]
 
* [[Image:Lecture_2_-_More_What_(Bio)Perl_can_do.ppt]]
 
* [[Image:Lecture_2_-_More_What_(Bio)Perl_can_do.ppt]]
* [[Perl_example_code]]
+
* [[Perl example code]]
 +
 
 +
== Command Prompt and Notepad ==
 +
 
 +
The command window or "Command Prompt" is found by opening the "Start" menu, choosing "Programs", then "Accessories", and then selecting "Command Prompt".
 +
 
 +
When you start the Command Prompt, you will be able to look at the contents of a particular folder or directory, and the commands you use will do their work within that folder. The folder you start in will probably be your home folder.
 +
 
 +
Notepad is found in the same menu, but it can be easier to open Notepad by typing the <tt>notepad</tt> command in the Command Prompt window like this:
 +
 
 +
notepad example1.plx
 +
 
 +
This makes sure that the new file is created in the right place. In this case, it is called <tt>example1.plx</tt>. If you started Notepad from the menu, when you save the file you have to find your way to where your programs need to be stored, and that can take some time.
 +
 
 +
== DOS Commands ==
 +
 
 +
The Command Prompt uses a different set of commands to those you find in Perl: these commands are known as DOS commands.
  
 
You will need to know how to make your way around in a DOS command environment.
 
You will need to know how to make your way around in a DOS command environment.
Line 16: Line 30:
 
Especially these:
 
Especially these:
  
* dir
+
{| cellspacing="0" cellpadding="10" border="1" style="margin: 2em"
* mkdir
+
| dir
* cd
+
| Shows the contents of the current directory (folder)
* copy
+
|-
* move
+
| mkdir ''name''
* del
+
| Makes a new directory called ''name''
* cls
+
|-
* echo %PATH%
+
| cd ''name''
* CTRL+c (Holding down "control" and c will terminate a programme - useful if you have accidentally programmed an infinite loop that you want to stop).
+
| Enters the directory called ''name''
 +
|-
 +
| cd ..
 +
| Goes up and out of the current directory
 +
|-
 +
| copy ''source'' ''target''
 +
| Makes a copy of ''source'' with the name ''target'', or makes a copy of ''source'' with the same name inside a directory called ''target'' (if present)
 +
|-
 +
| move ''source'' ''target''
 +
| Moves ''source'' inside a directory called ''target'' (if present)
 +
|-
 +
| rename ''oldname'' ''newname''
 +
| Renames ''oldname'' to ''newname''
 +
|-
 +
| del ''name''
 +
| Deletes the file called ''name'' (be careful!)
 +
|-
 +
| cls
 +
| Clears the console/terminal
 +
|-
 +
| echo %PATH%
 +
| Shows the list of places where the system looks for programs
 +
|-
 +
| Ctrl+C (holding down Ctrl and C)
 +
| Terminate a program - useful if you have accidentally programmed an infinite loop that you want to stop
 +
|}
 +
 
 +
== Unix Commands ==
 +
 
 +
If you are using GNU/Linux or Mac OS X, you will be using different commands:
 +
 
 +
{| cellspacing="0" cellpadding="10" border="1" style="margin: 2em"
 +
| ls
 +
| Shows the contents of the current directory (folder)
 +
|-
 +
| mkdir ''name''
 +
| Makes a new directory called ''name''
 +
|-
 +
| cd ''name''
 +
| Enters the directory called ''name''
 +
|-
 +
| cd ..
 +
| Goes up and out of the current directory
 +
|-
 +
| cd
 +
| Goes to your home directory
 +
|-
 +
| cp ''source'' ''target''
 +
| Makes a copy of ''source'' with the name ''target'', or makes a copy of ''source'' with the same name inside a directory called ''target'' (if present)
 +
|-
 +
| mv ''source'' ''target''
 +
| Renames ''source'' to ''target'', or moves ''source'' inside a directory called ''target'' (if present)
 +
|-
 +
| rm ''name''
 +
| Deletes the file called ''name'' (be careful!)
 +
|-
 +
| clear
 +
| Clears the console/terminal
 +
|-
 +
| echo $PATH
 +
| Shows the list of places where the system looks for programs
 +
|-
 +
| Ctrl+C (holding down Ctrl and C)
 +
| Terminate a program - useful if you have accidentally programmed an infinite loop that you want to stop
 +
|}

Latest revision as of 11:20, 9 May 2012

This introduction to Perl is taught as part of MBV-INF4410/9410 and MBV3070.

Slides for the "Introduction to Perl" lectures:

Command Prompt and Notepad

The command window or "Command Prompt" is found by opening the "Start" menu, choosing "Programs", then "Accessories", and then selecting "Command Prompt".

When you start the Command Prompt, you will be able to look at the contents of a particular folder or directory, and the commands you use will do their work within that folder. The folder you start in will probably be your home folder.

Notepad is found in the same menu, but it can be easier to open Notepad by typing the notepad command in the Command Prompt window like this:

notepad example1.plx

This makes sure that the new file is created in the right place. In this case, it is called example1.plx. If you started Notepad from the menu, when you save the file you have to find your way to where your programs need to be stored, and that can take some time.

DOS Commands

The Command Prompt uses a different set of commands to those you find in Perl: these commands are known as DOS commands.

You will need to know how to make your way around in a DOS command environment. Useful sites that may be useful to read before/during the exercises are:

Especially these:

dir Shows the contents of the current directory (folder)
mkdir name Makes a new directory called name
cd name Enters the directory called name
cd .. Goes up and out of the current directory
copy source target Makes a copy of source with the name target, or makes a copy of source with the same name inside a directory called target (if present)
move source target Moves source inside a directory called target (if present)
rename oldname newname Renames oldname to newname
del name Deletes the file called name (be careful!)
cls Clears the console/terminal
echo %PATH% Shows the list of places where the system looks for programs
Ctrl+C (holding down Ctrl and C) Terminate a program - useful if you have accidentally programmed an infinite loop that you want to stop

Unix Commands

If you are using GNU/Linux or Mac OS X, you will be using different commands:

ls Shows the contents of the current directory (folder)
mkdir name Makes a new directory called name
cd name Enters the directory called name
cd .. Goes up and out of the current directory
cd Goes to your home directory
cp source target Makes a copy of source with the name target, or makes a copy of source with the same name inside a directory called target (if present)
mv source target Renames source to target, or moves source inside a directory called target (if present)
rm name Deletes the file called name (be careful!)
clear Clears the console/terminal
echo $PATH Shows the list of places where the system looks for programs
Ctrl+C (holding down Ctrl and C) Terminate a program - useful if you have accidentally programmed an infinite loop that you want to stop