in reply to Re: Logging to web page with Mojolicious and strict
in thread Logging to web page with Mojolicious and strict
index.mojo:
BigFileFullOfSubs.pl:#!/usr/bin/perl use Mojolicious::Lite; my $logLine; require './bigFileFullOfSubs.pl'; require './subImWorkingOn.pl'; any '/' => sub { my $c = shift; $logLine = ""; subImWorkingOn(); $c->stash(logLine => $logLine); $c->render(template => 'main'); }; app->start; __DATA__ @@ main.html.ep <!DOCTYPE html> <html><head></head> <body> <pre> <%= $logLine %> </pre> </body> </html>
SubImWorkingOn.pl:#!/usr/bin/perl -w use strict; use warnings; sub Log { # Generates nice looking log comment with time. my ($LogItem) = @_; $LogItem =~ s/\n/ /g; my $Time = "functionThatGetsTheTime()"; my $thisLog = "[ $Time ] :: $LogItem\n"; $logLine .= $thisLog; } return 1;
Error message:use warnings; use strict; sub subImWorkingOn { Log("Interesting information for the user here."); Log("Even more fascinating information for the user here!"); Log("Processing complete"); } return 1;
Global symbol "$logLine" requires explicit package name (did you forg +et to declare "my $logLine"?) at ./bigFileFullOfSubs.pl line 11.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Logging to web page with Mojolicious and strict
by hippo (Archbishop) on Sep 12, 2019 at 15:56 UTC | |
|
Re^3: Logging to web page with Mojolicious and strict
by Anonymous Monk on Sep 12, 2019 at 19:38 UTC | |
by TieUpYourCamel (Scribe) on Sep 13, 2019 at 19:52 UTC |