Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

reading commands from configuration file

by Sun751 (Beadle)
on Jul 03, 2009 at 01:27 UTC ( [id://776888]=perlquestion: print w/replies, xml ) Need Help??

Sun751 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: reading commands from configuration file
by afoken (Chancellor) on Jul 03, 2009 at 08:39 UTC

    Sun751 prefers to create a new thread for each tiny aspect of the real problem.

    Sun751, it would be easier to stay in one thread for the entire problem, this would give other monks more context to work with, and it would avoid repeated answers that don't help you. Of course, it would be helpful to explain the real problem.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: reading commands from configuration file
by belg4mit (Prior) on Jul 03, 2009 at 01:49 UTC
    You don't give us much to go by here, but I suspect do EXPR i.e; eval a file; might be a good place to start. As long as your commands are valid perl expression (including self-defined subroutines), it'll just work.

    --
    In Bob We Trust, All Others Bring Data.

Re: reading commands from configuration file
by graff (Chancellor) on Jul 03, 2009 at 14:05 UTC
    As you should know from reading ikegami's reply on your other thread about this problem, if you want to run a set of commands "in sequential order one by one", you want these things in an array (or maybe an array of hashes, as ikegami suggested), not in a hash.

    Assuming that the sequence of commands does not involve anything that requires manual interaction by prompting for user input from "stdin", the easiest thing is to have the list of commands as plain text, one command per line, and execute each one in turn, in any of several ways.

    With unix/linux, this sort of text file is also known as a "shell script", which could just be executed on its own using the shell (e.g. source command_list.file or just  . command_list.file) -- no need for perl, really.

    Is there something you need to do that a simple shell script doesn't do for you?

Re: reading commands from configuration file
by Marshall (Canon) on Jul 03, 2009 at 02:27 UTC
    It is not clear to me what you are trying to do. The most simple way to do this is a shell script or a .bat file if there are no decisions to be made.

    In general, I would recommend against putting any code that you run with eval{} into a config file. There can be very good reasons to do this, but until you understand what they are, DON'T do it. There can be big security holes with this and very unexpected results can result.

    There are a number of great Perl modules that can help with this. Can you give us say 5 lines of input and what you figure those 5 lines should do?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://776888]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-19 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found