not well-formed (invalid token) at line 2, column 0, #### #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use File::Slurp; use PDF::FromHTML; my $temp_location = "tmp"; my $location = "converted"; my $pdf = PDF::FromHTML->new( encoding => 'utf-8' ); my $all_pdf = get_pdf(); convert_to_pdf($all_pdf); sub get_pdf { opendir DIR, $temp_location; my @files = grep !/^\.{1,2}$/, readdir(DIR); if( @files == 0 ) { print "\n No files at this time.\n\n"; } return \@files; closedir(DIR); } # End Sub sub convert_to_pdf { my $get_files = shift; foreach my $file ( @{$get_files} ) { # Loading from a file: $pdf->load_file($temp_location."/".$file); # Perform the actual conversion:  $pdf->convert(); # Write to a file: $pdf->write_file($location."/".$file); } }# End Sub