Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on perl reports using 'format' command.

Status
Not open for further replies.

carlebrisson

Programmer
Joined
Jun 16, 2005
Messages
2
Location
CA
I would like to run reports but store the actual formats in external files. The problem is I don't know how to make the variables local to both perl scripts. If anyone has any better method of achieving this, it would be much appreciated. Obviously, this example does not work.

i.e.:

[test.pl]
#!/usr/bin/perl

use English;

require "my.rpt";

my $name = "Joe Bloe";
$FORMAT_NAME = "REP1";
write;

[my.rpt]
#!/usr/bin/perl

format REP1 =

Hi my name is @<<<<<<<<<<<<<<<<<<<
$name
.
 
Quick starter for you:
Code:
      test.pl
#!/usr/bin/perl
use English;
my $format = "";
open FH, "my.rpt" or die "Failed to open formats";
$format .= $_ while(<FH>);
close FH;
eval $format;
$main::name = "Joe Bloe";
$FORMAT_NAME = "REP1";
write;
Code:
      my.rpt
format REP1 =
Hi my name is @<<<<<<<<<<<<<<<<<<<
$main::name
.

That seems to work but I could only make it use the main:: globals. I guess with tinker time I might be able to sort out the scoped vars but I'll leave that to you if you need it.



Trojan.
 
Thanks Trojan. The $main scoped vars will be sufficient at this time. That's what I was missing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top