I translated the Go example to Perl by making simple syntax transformations:
- Printing is done with
say
instead offmt.Println
. - Variables have a sigil that define their "type", for example,
$a
instead ofa
. - Address of a variable is return with
\
instead of&
. - References/Pointers are dereferenced with
$
instead of*
. - Comments are made with
#
instead of//
. - Perl requires semicolons.
Here's the program: