Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
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:


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

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


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 do a chmod +x and then try running it by just typing at your command prompt. With any luck it should print out:

Hello World!
Now you should check out the basic datatypes, three

In reply to The basics by root

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.