keen2learn has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm having to convert my dashboard in a hurry because I've moved to a new server and 'use lib' to locate external scripts for my html output, no longer works. Hence my quickly, to get to know modules. The module I have created, displays inconsistently. After I edit the output and clearing browser cache, it often shows old data from an earlier attempt, and rotates on 'refresh' between new an old content. I wonder if there is a caching aspect with modules (perhaps @EXPORT) that I am unaware of? So, would anyone please, be willing to troubleshoot and advise on this first attempt at a module. Main script
#!/usr/bin/perl -w use strict; use warnings; use CGI; use Data::Dumper; my $cgi = new CGI; # add the library dir to @INC; use lib do { use Cwd 'realpath'; my ($dir) = __FILE__ =~ m{^(.*)/}; realpath("$dir/library"); }; use feature 'say'; use FindBin '$RealBin'; use lib $RealBin; use lib "$RealBin/library"; print $cgi->header; use HtmlHeader; my %doctypeAndTitle = header(); say $doctypeAndTitle{doctypeAndTitle}; #output inconsistent 1;
Here's the module
package HtmlHeader; use strict; use warnings; use parent 'Exporter'; our @EXPORT_OK = qw[ header ]; sub header { my $doctypeAndTitle = getDoctypeAndTitle(); my %doctypeAndTitle = ( doctypeAndTitle => $doctypeAndTitle ); return %doctypeAndTitle; } sub getDoctypeAndTitle{ my $doctype = "<!doctype html> <html> <head> <title>My Page Title</title> "; return $doctype; } 1;

Replies are listed 'Best First'.
Re: Module inconsitency
by tobyink (Canon) on Oct 18, 2020 at 20:49 UTC

    I suspect your hosting is set up with some kind of caching at the web server level (Apache, nginx, etc) or perhaps even using a content-distribution network like CloudFlare which is serving up old copies of your pages.

Re: Module inconsitency
by keen2learn (Novice) on Oct 19, 2020 at 03:01 UTC
    Thank you folks. I was convinced it was a server caching issue but had been told it was my scripts which they couldn't offer support on. I wrote three different type of modules and had the same results each time. After saying I would leave I got a quick response with a solution which was, as you mentioned, a server caching issue and, which they addressed. Not the fanatical support I thought they provided though I've no complaint about any individual tech.

      Just to remember: use CGI qw/-debug/; See also

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Re: Module inconsitency
by Anonymous Monk on Oct 18, 2020 at 19:46 UTC
    What webserver tech are you using?
Re: Module inconsitency
by perlfan (Parson) on Oct 19, 2020 at 18:21 UTC
    If possible, I recommend moving to a VPS or provision a cloud server. There are several recent threads on this here. But relying on a shared webhosting account for anything other than a cookie blog is a waste of money and power.
      Good to know, though, I'm on a dedicated server.