• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 941
  • Last Modified:

compile and run a perl program

how to compile and run a perl program that outputs the hello world to the unix screen.
  • 2
  • 2
1 Solution
Do you mean compile as in "Compile into an .exe file" or compile as "execute the script"?

Also, details about what type of system your using will be helpful.
I'm blind.  You put Unix. :(

Try using pp - I haven't used it myself, but it is supposed to be able to create executable Perl files for distribution.

Hi mordi,

Do you mean a simple hello world script to echo on console screen on Unix?  First you need to install perl, which you can download from http://www.perl.com/pub/a/language/info/software.html, then you just need to test first script this way:

perl -e 'print "hello, world\n"'

The script is enclosed in the single quotes, if you want the script to standalone name this code test.pl:


print "hello, world\n";

Then launch the script by typing "perl test.pl" or "./test.pl" if you chmod-ed to 0755 for example.

That's it.  You don't really need to compile a perl program because perl interpreter will do it on-the-fly for you.

mordiAuthor Commented:
could an output of a ls command be printed in the screen from a perl program?
use this code:

open(IN, "ls |"); # open a pipe to read ls command's output
while(<IN>) # read pipe line by line into $_ ($_ is special so you don't need $_ = <IN> syntax
  print; # print line by line (it's printing the default $_ variable, which is storing the line)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now