How to Use PERL on Redhat

Red Hat Enterprise Linux (RHEL) has the Perl programming language installed natively. You can create a Perl script and execute it without installing any additional software. The first line of the script must be a shebang (#!) followed by the path to the Perl interpreter. RHEL places the Perl interpreter in the "/usr/bin" directory. You do not have to create the a script file, you can type a single line of code on the command line, if you prefer.

Instructions

  1. Perl Script

    • 1

      Open a blank plain text document in any text editor.

    • 2

      Type the line

      #!/usr/bin/perl

      to start the Perl script.

    • 3

      Type the rest of the Perl script.

    • 4

      Save the file with the ".pl" file extension to indicate that it is a Perl script.

    • 5

      Type the command "perl filename.pl" at a command prompt to execute the script. Replace "filename" with the name you gave the script.

    Perl One-liner

    • 6

      Open a terminal window or log in to the computer via an SSH session to access a command line.

    • 7

      Type the line "perl -e 'print 'Hello Universe! \n";' to create the single line script. You can type any Perl code between the single quotes.

    • 8

      Press the "Enter" key to execute the Perl script.

Tips & Warnings

  • You can type "chmod +x filename.pl" to make a Perl file executable then type "./filename.pl" at the command line to execute it.

Related Searches:

References

Resources

Comments

Related Ads

Featured