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

root
 2005-11-20 20:45
#55914 #55914
User since
2003-08-15
120 Artikel
BenutzerIn
[default_avatar]
Jetzt habe ich mir sowas gebaut, das ist auch sehr nett, aber ich muss nach wie vor dem sub erstmal etwas geben. Schön ist aber dass ich an die Variable dann ran komme und etwas im Hauptprogramm ändern kann ohne es mit return zurück zu geben.
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 qw(%template @EXPORT_OK);
#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
#use MyConf '%template';
sub test{
my $in = shift;
print "Bin in test:".$$in{'site'}."<br>\n";
$$in{'site'} = "news";
}
1;


Könnte ich der ganzen unterdatei irgendwie die Referenz geben? :-)

View full thread lokale Variable aus Sub ins Hauptprogramm!