Thread lokale Variable aus Sub ins Hauptprogramm! (30 answers)
Opened by skontox at 2003-09-24 21:07

root
 2005-11-22 21:34
#55926 #55926
User since
2003-08-15
120 Artikel
BenutzerIn
[default_avatar]
also sorry jungs aber das hilft mir für externe dateien nicht weiter!

1. datei:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl -w
#package MyConf;
use strict;
use warnings;
use vars '%template';
#use base 'Exporter';
#@EXPORT_OK = qw(%template);
require "rootssubs.sub";

my %template = ("site" => "home");
my $template_ref = \%template;

print "Content-type: text/html\n\n";

&test($template_ref);
print "in main: ".$template{'site'}."<br>\n";
exit(0);


Code: (dl )
1
2
3
4
5
6
7
8
use vars '%template';
sub test{
my $in = shift;
print "Bin in test:".$$in{'site'}."<br>\n";
print "Bin in test:".$template{'site'}."<br>\n";
$$in{'site'} = "news";
}
1;


output:
Code: (dl )
1
2
3
Bin in test:home
Bin in test:
in main: news


Ihr fachsimpelt hier welche Lösung die schönste ist und bei mir funktioniert keine einzige...

kann bitte mal einer ein beispiel mit zwei dateien und einem globalen Hash machen?!

Danke!!! Ich bin nämlich am verzweifeln!

View full thread lokale Variable aus Sub ins Hauptprogramm!