The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Beautifier - Perl extension for beautifying/styling/prettyprinting perl code.


  use Beautifier;

  my $beautifier = new Beautifier;
  print $beautifier->Beautify(
                        {'indent' => "  "},
                        "$this = 'some perl code';\n";


This module pretty prints/beautifies perl code. It does 3 things: - Indenting - Spacing around () and = and so forth - Curly placing

This might come in handy when working on other people's code (don't you hate that?) It uses my coding conventions, like placing the curly on the next line. Feel free to change it to your style (which, if different from mine, is wrong ;) Here is what code will look like after it's been crunched by Beautifier:

  if (($varName =~ m//) && (-f $fileName))
    print "Hello, world!\n";

WARNING: A working program might no longer work after Beautifier did her thing on it. (Beautifier is definitely female)


  #!/usr/bin/perl -w

  use strict;
  use Beautifier;

  undef $/; ### To read file all in one swoop
  open (FH, "") || die $!;
  my $fileContent = <FH>;
  close (FH);
  $/ = "\n"; ### Back to default

  my $beautify = new Beautifier;
  print $beautify->Beautify(
                            { 'indent' => "  ",


Teun van Eijsden, <>