Jump to content


- - - - -

[Perl Programming] Tutorial 1


  • Please log in to reply
10 replies to this topic

#1 sharkbate24

sharkbate24

    Private Pilot - IFR

  • Members
  • PipPipPipPip
  • 943 posts

Posted 11 June 2009 - 09:32 AM

Hello everyone,

In school, I'm studying Perl programming, so I thought I'd share my knowledge with you. I hope you enjoy, and if you have any questions, please don't hesitate to ask.
----------------------------------------------------------------------------------------------------------------------------------------------

Requirements:
You will require a FREEWARE program called "ActivePerl" to run Perl scripts on your home computer. This program can be grabbed from: http://www.activestate.com/activeperl/

You will also need a text editing program - Notepad is fine.

What is Perl?
Perl is an interpreted programming language mostly used for web applications. While Perl can be used for desktop applications, it's recommended that you learn a different programming language if you do want to create desktop applications. Perl is well known for it's strong and file manipulation. Best of all, it's easy to learn!

Your first program - Hello World.
Open up Notepad, or another similar text editing program, and enter the following code:

#!(YOUR PATH TO PERL.EXE HERE SUCH AS C:/PERL/BIN/PERL.EXE)
print 'Hello World';

Save the program as hello.pl.

Open up your command prompt, and go to the directory where you have saved hello.pl. Say for example, it was saved in "my documents", the command you would type in is:

CD my documents

Now, type in the following into the command prompt:

perl hello.pl

The program should say "Hello World" to you. Congratulations, you have just written your first PERL application!

Analysis
So you're probably wondering what all the code did?

The first line gives the directory of Perl. The # symbolises that the line is a comment and should be ignored by the interpreter (Perl).

The second line 'prints' / outputs text to the screen. The " ' " are extremely important, otherwise Perl will treat Hello World as a command rather than text to be outputted.

Also, note the " ; ", this should end most of the lines of code you write in Perl.

----------------------------------------------------------------------------------------------------------------------------------------------

I hope this has helped,
Thanks!

Edited by sharkbate24, 11 June 2009 - 09:34 AM.


#2 .Sam.

.Sam.

    Commercial Pilot

  • Members
  • PipPipPipPipPip
  • 1,194 posts
  • Location:England,oxfordshire

Posted 11 June 2009 - 11:19 AM

Yay

:hrmm:

#3 SwitchFX

SwitchFX

    formerly TeleFarsi_Airlines818

  • Members
  • PipPipPipPipPipPipPipPip
  • 30,764 posts

Posted 11 June 2009 - 05:31 PM

Perl is outdated and is behind Coldfusion and PHP. Though Adobe's AIR is supposed to be the latest craze in web driven and OS driven applications.

Edited by SwitchFX, 11 June 2009 - 05:31 PM.


#4 TopDollar

TopDollar

    Commercial Pilot

  • Members
  • PipPipPipPipPip
  • 1,823 posts
  • Location:the future

Posted 12 June 2009 - 06:31 PM

View PostSwitchFX, on Jun 11 2009, 06:31 PM, said:

Perl is outdated and is behind Coldfusion and PHP. Though Adobe's AIR is supposed to be the latest craze in web driven and OS driven applications.
Doesn't mean Perl isn't a great way to start to learn programming.

#5 SwitchFX

SwitchFX

    formerly TeleFarsi_Airlines818

  • Members
  • PipPipPipPipPipPipPipPip
  • 30,764 posts

Posted 12 June 2009 - 06:59 PM

It would be wiser to start in PHP.

#6 sharkbate24

sharkbate24

    Private Pilot - IFR

  • Members
  • PipPipPipPip
  • 943 posts

Posted 13 June 2009 - 07:35 AM

View PostSwitchFX, on Jun 12 2009, 06:59 PM, said:

It would be wiser to start in PHP.

PHP is not as good as Perl when it comes to file handling. A lot of beginner programmers chose to learn Perl as their first language because it's simple. For example, rather than using a loop, you can just use "x 100" to loop the command 100 times. It's really for whatever you find easier. If you want to get a job straight after learning programming, PHP may be the choice for you. However, if you want to be a hobbyest, and maybe a job worker later (will take longer than PHP), Perl is for you.

#7 FlightSimmer0724

FlightSimmer0724

    Airline Transport Pilot

  • Members
  • PipPipPipPipPipPip
  • 2,437 posts
  • Location:New York

Posted 14 June 2009 - 06:43 PM

Nice tutorial :hrmm:

#8 SwitchFX

SwitchFX

    formerly TeleFarsi_Airlines818

  • Members
  • PipPipPipPipPipPipPipPip
  • 30,764 posts

Posted 17 June 2009 - 03:33 AM

View Postsharkbate24, on Jun 13 2009, 05:35 AM, said:

View PostSwitchFX, on Jun 12 2009, 06:59 PM, said:

It would be wiser to start in PHP.

PHP is not as good as Perl when it comes to file handling. A lot of beginner programmers chose to learn Perl as their first language because it's simple. For example, rather than using a loop, you can just use "x 100" to loop the command 100 times. It's really for whatever you find easier. If you want to get a job straight after learning programming, PHP may be the choice for you. However, if you want to be a hobbyest, and maybe a job worker later (will take longer than PHP), Perl is for you.
PHP = Industry standard. You're better of learning it if you want to take serious jobs. Most, if not all web-based scripts are built from the ground up using PHP. Whether PHP will be a viable option say in 5 years is up to the current users. Coldfusion is getting more and more attention as time goes by.

Edited by SwitchFX, 17 June 2009 - 03:41 AM.


#9 wildwobby

wildwobby

    Airline Transport Pilot

  • Members
  • PipPipPipPipPipPip
  • 2,601 posts
  • Location:USA

Posted 26 June 2009 - 12:50 AM

Perl is not out dated. What the heck are you talking about? Just because it isn't used for web applications as much anymore doesn't mean jack :hrmm:. Use a *nix box for 5 seconds and you will see that it is everywhere. Perl is more widely used than PHP... its a general purpose scripting language where as php isn't. You honestly need to learn what you are talking about before you shoot your mouth off like that. And PHP is the industry standard? Ummm.. no. there are so many scripting languages (even specifically for web development) that you can't call any one of them an industry standard. PHP, Perl, Python (+Django), ASPX, ColdFusion,etc.

You just have to use the right tool for the job. Depending on what the task is, perl is a much better language in most cases.

Edited by wildwobby, 26 June 2009 - 12:53 AM.


#10 Toyuko

Toyuko

    Commercial Pilot

  • Members
  • PipPipPipPipPip
  • 1,781 posts
  • Location:Sapporo, Japan

Posted 27 June 2009 - 06:24 PM

thx

#11 sharkbate24

sharkbate24

    Private Pilot - IFR

  • Members
  • PipPipPipPip
  • 943 posts

Posted 01 July 2009 - 08:45 AM

Ideally, a big difference between Perl and PHP is that with Perl, you can create console applications where as with PHP, you can't.

I don't want to start a PHP vs Perl war or anything; both languages has it's pro's and con's.

I know both languages, PHP and Perl; and I do think that programming web applications is easier in PHP than in Perl; but then again, that's just my opinion. One noticable difference is the documentation. In my opinion, PHP's documentation is much better than Perl's.

Thanks :hrmm:.