Perl

Installation and setup of Perl

  1. Download Windows version of Perl at ActiveState.
  2. Install it.
  3. Save the following code in a file and name it tutorial.perl.

    #!/usr/local/bin/perl
    print 'Hello world.';        # Print a message    
     
  4. Open the Command Prompt.
  5. Execute the following command: perl tutorial.perl
  6. It should display Hello world..

Variables

#!/usr/local/bin/perl
 
# Example showing how to define different variables.
# ==================================================
 
my $someString="Hello World!";  # Variable holding a string.
my $someNumber=3.1415;          # Variable holding a number.
my @someArray =("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
 
# Output all the variables defined.
$someNumber = $someNumber*2;
print "$someString\n";
print "$someNumber\n";
print "@someArray\n";