467,146 Members | 1,018 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

How can i create a config file?

I'm totally new here. Can someone provide me a short Perl script and its corresponding config file so that i can compare and base on it as my pattern? I appreciate the help, thanks.
I included a simple Factorial program (perl script) below with output to be printed in a text file..

Expand|Select|Wrap|Line Numbers
  1. $out="C:/0718/";
  2. print "Please specify what type of file you want to create :   ";
  3. chop ($inp=<STDIN>);
  4. print "What number to factor ? :  ";
  5. chop ($num=<STDIN>);
  6. open OUT, ">$out$inp" or die "Cannot open $out for write :$!";
  7.  
  8. $j=1;
  9. for ($i=1;$i<=$num;$i++)
  10.  
  11. {$j=$j*$i;
  12. print OUT "$j \t$i\n";}
  13. print OUT"The factorial of $num is $j \n";
  14.  
  15. print "Ok you can now check $out$inp \n";
  16.  
Thanks very much!

Monster
Jul 19 '08 #1
  • viewed: 1892
Share:
5 Replies
numberwhun
Expert Mod 2GB
First, the use of code tags is required in the forums. Please use them to surround any and all code that you place in your posts. This is your warning.


As for your request, this is a learning forum, not a scripting service. If you are just wanting someone to write the script for you, then please feel free to post a job opening in the Jobs forum and hopefully someone will take it if the pay is right.

Otherwise, you can post the code you have tried in order to do what you ask, if it isn't working, and we can assist you in getting it working, all the while, you can learn some Perl.

Also, what does the factorial script have to do with your request?

Regards,

Jeff
Jul 19 '08 #2
KevinADC
Expert 2GB
Do you have something that needs to read/write a configuration file? There are modules like Config::General and Config::Simple for that purpose but I am not sure if you mean an actual configuration file or something else. It is also inappropriate to PM members seeking personal assistance or quicker than normal replies to your questions. Makes me suspicious that this is school/class work, which is not allowed to be posted here.
Jul 19 '08 #3
First of all, thanks for the responses. Sorry for the confusion though.. I just want to know what does a config file do within a Perl script. I know this is something that a programmer can edit without creating any problem on the actual script? The reason I provided the simple factorial program is for me to know how to link a config file there. Yes Kevin, i think I need an actual config file for that simple script. Later on, I can do it myself once I got familiar on how the config file works against it.

Thanks Guys.

Monster
Jul 20 '08 #4
numberwhun
Expert Mod 2GB
First of all, thanks for the responses. Sorry for the confusion though.. I just want to know what does a config file do within a Perl script. I know this is something that a programmer can edit without creating any problem on the actual script? The reason I provided the simple factorial program is for me to know how to link a config file there. Yes Kevin, i think I need an actual config file for that simple script. Later on, I can do it myself once I got familiar on how the config file works against it.

Thanks Guys.

Monster
You are correct! A config file is a place to put values that may or do change. That way, you can change them at will without having to change the script. The more complex your script is, the less you really want to edit it.

The format of the config file is up to you but there are modules (as Kevin pointed out) to process them. One module that we use where I work is called "Config::Scoped". Its a rather complex module, but the possibilities with it will amaze you. Personally, if you are just beginning with config files, the modules Kevin mentioned would be better. Or, if you wish, you can process them yourself, as I have done many times.

Regards,

Jeff
Jul 20 '08 #5
Thanks Jeff, i'll take your advice. i will ask questions again once I bumped into an issue.
Jul 22 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by ferg | last post: by
2 posts views Thread by David Elliott | last post: by
2 posts views Thread by Vicky via DotNetMonster.com | last post: by
reply views Thread by mlafarlett@yahoo.com | last post: by
1 post views Thread by James Johnston | last post: by
2 posts views Thread by forest demon | last post: by
2 posts views Thread by Christian Muggli | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.