Warning: Creating default object from empty value in /home/patricknevindwyer/digilutionary.com/wp-includes/functions.php on line 292
digilutionary.com
Patrick Dwyer

Echo :: Perl

in News, Perl, Comparative Programming by patrick


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/patricknevindwyer/digilutionary.com/wp-includes/functions-formatting.php on line 76

This program is part of the Comparative Programming :: Echo set of examples.

This example could be a one liner in Perl, but we’ve stretched it to three lines to make sure it’s well formed. Besides a directive at the top of the file pointing to the Perl interpreter, and a single module ‘use’ statement, the body of our program is a single line joining all of our input arguments (provided automatically in @ARGV) with a space as the delimeter.

Perl
#!/usr/bin/perl

use strict;

print join(’ ‘, @ARGV) . "\n";

Program Source: echo.pl

Running the example

From the command line:

perl echo.pl Hello World