How to write a very simple script in perl?
-
As always starting off with a Hello World script. Create file in your home directory with the following code and make it executable by running:
$ chmod +x myperl1
#!/usr/bin/perl print "Hello, World!\n";
Run the script
$ ./myperl1 Hello, World!
Newer versions of perl v5.10+ have another way of printing out output, but you have to specify the version in the script to use.
#!/usr/bin/perl use v5.22; say "Hello, Universe";
$ ./myperl1 Hello, Universe
© Lightnetics 2024