Hello! I'm quite new at Perl and trying to build a config file written in perl and then pull it into a main file to setup variables. I've read the tutorials but still fail to grasp the concept. What am I doing wrong and how should I do it? I've been at it for 1.5 day now. Code is shortened since the config file is rather large but the concept is the same.
#!/usr/bin/perl -w use strict; use warnings; my $MATCH_FILE="/path/to/patterns.pl"; my @LOGE; # this is an array that should be "configured" by the patter +n.pl my $return; unless ($return = do $MATCH_FILE) { warn "couldn't parse $MATCH_FILE: $@" if $@; warn "couldn't do $MATCH_FILE: $!" unless defined $retu +rn; warn "couldn't run $MATCH_FILE" unless $return; } print $return; # this prints 2 printLogPatterns(@LOGE);
In this file I want to set the @LOGE file to a variable set in the patterns.pl file.
#pattern.pl use strict; use warnings; my $astring = "This is an example string"; # not accessed @LOGE = ( { HASH => "a hash"},{ HASH => "Another one"} ); # this is wh +at I want to be "exported" sub asub{ print "a sub"; }# is this also possible to "export"?
I'd like to use a pulled in perl config file since it would be good to configure the application quite fast and the possibilities looked very promising. Any help is appreciated
In reply to Making use of a config file written in Perl by noodleish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |