2

I created my mojolicious-lite app on my own(just created files I needed manually instead of using the "create app" commands). I am following along with the tutorial here: https://www.perl.com/article/193/2015/9/18/How-to-send-verification-emails-using-Mojolicious/

When trying to use any command line commands with my app I am getting errors. From the tutorial specifically I am trying to run:

./hello.pl minion job

But more generally I also notice no commands seem to be working for me e.g:

./hello.pl help
./hello.pl routes

The error seems to be with parsing of my postgres helper? Here is the exact error message:

./hello.pl help
./hello.pl: line 1: use: command not found
./hello.pl: line 2: use: command not found
./hello.pl: line 3: use: command not found
./hello.pl: line 4: use: command not found
./hello.pl: line 5: use: command not found
./hello.pl: line 6: use: command not found
./hello.pl: line 7: use: command not found
./hello.pl: line 10: syntax error near unexpected token `('
./hello.pl: line 10: `helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test_users') };'

My app is working fine other than invoking commands from the command line.

Here are the first 11 lines of my app:

use Mojolicious::Lite;
use Mojo::ByteStream;
use Mojo::JWT;
use Mojo::Pg;
use Mojolicious::Plugin::Bcrypt;
use Mojolicious::Plugin::Minion;
use Data::Dumper;


helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test_users') };
app->pg->migrations->from_data->migrate;
Dont9889
  • 133
  • 1
  • 4
  • 1
    Your code is running as a shell script and not through the perl interpreter. Run as `perl hello.pl ...` or add a shebang line. – mob Jun 17 '18 at 15:53
  • ***Always*** `use strict` and `use warnings 'all'` at the top of every Perl program you write. – Borodin Jun 17 '18 at 15:55
  • @mob: Please write up an answer. – Borodin Jun 17 '18 at 15:56
  • @Borodin [Mojolicious::Lite](https://metacpan.org/pod/Mojolicious::Lite#SYNOPSIS) "*Automatically enables "strict", "warnings", "utf8" and Perl 5.10 features*". – melpomene Jun 17 '18 at 23:16
  • @mob Although the correct answer (add a shebang line) might be the same this is not at all a duplicate of a hello world program. – memowe Jun 20 '18 at 09:35

0 Answers0