So you want to learn Perl eh??? If you're unsure of that much you might want to check What is Perl?
The first thing you might be asking is how do you run a Perl program? The way to do it on most systems is by simply typing:
perl program.pl
This will work so long as perl is on your system and your PATH points to where it is stored. If you're on a Unix or This will make your computer read this as a series of shell commands stored in a file. However this isn't quite what we want. We want it to first run the perl interpreter and then have that process and run the rest of the program.Linux system another more common way of running your program is to make it executable. To do this you type something like
chmod +x programfile.pl
To do this we have to add one line at the beginning of the program file. Most of the time that looks something like this
#!/usr/bin/perl
If this doesn't work your perl interpreter may be in another location to find out where that might be you could type
where perl
to find where it's stored if this yields something like /usr/contrib/bin/perl simply change that first line to #!/usr/contrib/bin/perl and you should be golden.
To make sure all that is working we may as well write up the obligatory "Hello World" program to test it out. How about something like:
Now save that in a file like helloworld.pl do a chmod +x helloworld.pl and then try running it by just typing helloworld.pl at your command prompt. With any luck it should print out:
Hello World!
Now you should check out the basic datatypes, three
The first thing you might be asking is how do you run a Perl program? The way to do it on most systems is by simply typing:
perl program.pl
This will work so long as perl is on your system and your PATH points to where it is stored. If you're on a Unix or This will make your computer read this as a series of shell commands stored in a file. However this isn't quite what we want. We want it to first run the perl interpreter and then have that process and run the rest of the program.Linux system another more common way of running your program is to make it executable. To do this you type something like
chmod +x programfile.pl
To do this we have to add one line at the beginning of the program file. Most of the time that looks something like this
#!/usr/bin/perl
If this doesn't work your perl interpreter may be in another location to find out where that might be you could type
where perl
to find where it's stored if this yields something like /usr/contrib/bin/perl simply change that first line to #!/usr/contrib/bin/perl and you should be golden.
To make sure all that is working we may as well write up the obligatory "Hello World" program to test it out. How about something like:
#!/usr/bin/perl print "Hello World!\n";
Now save that in a file like helloworld.pl do a chmod +x helloworld.pl and then try running it by just typing helloworld.pl at your command prompt. With any luck it should print out:
Hello World!
Now you should check out the basic datatypes, three
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: The basics
by Anonymous Monk on Jun 24, 2006 at 18:47 UTC | |
by Joost (Canon) on Jun 24, 2006 at 19:17 UTC | |
by Hue-Bond (Priest) on Jun 24, 2006 at 21:59 UTC | |
by Tanktalus (Canon) on Jun 25, 2006 at 14:25 UTC | |
by Hue-Bond (Priest) on Jun 25, 2006 at 14:35 UTC | |
by tye (Sage) on Jun 25, 2006 at 05:55 UTC | |
Re: The basics
by Anonymous Monk on Oct 10, 2008 at 10:18 UTC | |
by monkmoose (Initiate) on Jan 05, 2009 at 20:52 UTC | |
by raschipi (Initiate) on Dec 11, 2011 at 13:26 UTC | |
by cavac (Parson) on Dec 11, 2011 at 14:50 UTC |
Back to
Tutorials