w8lle has asked for the wisdom of the Perl Monks concerning the following question:
Hi!
I have a main script and a module I created myself:
main.pl:
#!/usr/bin/perl use strict; use warnings; use lib "."; use failingFormat qw (&printFormat); printFormat ("TEST", "Testing to print the TEST format.");
failingFormat.pm:
#!/usr/bin/perl use strict; use warnings; use Exporter; my $PKG = "failingFormat"; our $VERSION = "0.0.01"; our @ISA = qw (Exporter); our @EXPORT_OK = qw ( &printFormat ); my $text2print; sub printFormat { $~ = shift; $text2print = shift; write; $~ = "STDOUT"; } format TEST = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $text2print ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $text2print . 1;
In Perl v5.8.8, this works OK, but in v5.10.0 it complains about $text2print being uninitialized. To get this to work, I have to declare $text2print in main.pl:
our $text2printAnd then use that parameter in my module ($main::text2print).
Is that a feature or a fault introduced in the later version?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Must use global variables in format in module; feature or fault?
by Anonymous Monk on Aug 22, 2012 at 02:42 UTC | |
by w8lle (Novice) on Aug 22, 2012 at 17:30 UTC |