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

I'm getting compilation errors:
Global symbol "%xinfo" requires explicit package name at pat.pl line 17
Global symbol "%addr1" requires explicit package name at pat.pl line 18
Heres the code:
use strict; no strict 'refs'; # stop complaints about hard references use warnings; no warnings 'once'; # no warnings if only indirect data accesses sub display_data(); sub dump_data(); format STDOUT_TOP = Payment To Address ---------------------------------------- -------------------- +------ . format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< +<<<<<< { $xinfo{PAYTO}, $addr1{LINE} } . $|++; # autoflush our ( %data, %addr1, %addr2, %xinfo ); my $hash; @ARGV= 'vendshrt'; while (<>) { chomp; my ($field, $value) = split ' ', $_, 2; unless ($field) { next unless $hash; write STDOUT; undef $hash; } else { $field =~ s/\.//g; if ($field =~ /VENDOR_LIBRARY/) { $hash = 'data'; next; } if ($field =~ /(ADDR1|ADDR2|XINFO)/) { my $section = lc $1; $hash = $field =~ 'BEGIN' ? $section : 'data'; } else { $hash->{$field} = $value; } } }
What syntax do I need where?
email: pgo@bnl.gov PGO

Replies are listed 'Best First'.
Re: Execution Errors
by pfaut (Priest) on Feb 06, 2003 at 20:23 UTC

    The format statements reference those hashes. They are not yet in scope because they haven't yet been declared. Move the declaration of the hashes before the format statements.

    --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';