Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Including files

by jidanni (Initiate)
on May 28, 2017 at 23:57 UTC ( #1191461=note: print w/replies, xml ) Need Help??


in reply to Including files

Nowadays,
$ cat config.pl # This is config.pl mirror => 'http://www.nl.example.com/mirror', path => '/var/www/example', skip_files => [ 'png', 'gif', 'jpg' ], $ cat script.pl # This is script.pl use strict; my %config = do 'config.pl'; chdir $config{path}; $ perl script.pl $ perl -w script.pl Odd number of elements in hash assignment at script.pl line 3. Use of uninitialized value in list assignment at script.pl line 3. Use of uninitialized value $config{"path"} in chdir at script.pl line +4. $

Replies are listed 'Best First'.
Re^2: Including files
by afoken (Abbot) on May 29, 2017 at 19:24 UTC

    I would avoid configuration files containing executable code. There are many better alternatives: Re: Accessing variables in an external hash without eval

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^2: Including files
by haukex (Abbot) on May 29, 2017 at 08:49 UTC
    Nowadays,

    FWIW, the code still works fine for me under 5.24.1 on Linux. However, I can suggest you try replacing 'config.pl' by './config.pl', as discussed here. Also, it's a good idea to add the error checking to do as shown in its documentation.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1191461]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-12-18 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (500 votes). Check out past polls.

    Notices?