473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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
5 2224
numberwhun
3,509 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
4,059 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
3,509 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

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

Similar topics

4
by: ferg | last post by:
I've checked all the FAQs and help - spent a couple of hours on this now and it's really bugging me. I've got Moin 1.3.5 installed on IIS 5.0. I can view and edit pages without any problems, but...
2
by: David Elliott | last post by:
I can create this: ?xml version="1.0" standalone="yes" ?> <ConfigOpt> <record> <Field_1>Text # 1</Field_1> <Field_2>Text # 2</Field_2> </record> </ConfigOpt>
2
by: Vicky via DotNetMonster.com | last post by:
Hi, Could anyone help me with some info how to create app.config file. I need to put code of directory info in there, Thank you very much! DirectoryInfo di = new DirectoryInfo("C:\\Vicky...
6
by: Rich | last post by:
Hello, I picked up this example on using the Reflection namespace for loading forms/classes on the fly at msdn http://msdn.microsoft.com/library/default.asp?...
3
by: Madhu | last post by:
All, New to DB2 environment. Can someone share a script that can be used to a create a DB2 UDB database manually. I am trying to create a database on Linux, single partition. Thanks Madhu
0
by: mlafarlett | last post by:
Geez...seems like i've compared every friggin character...works n this programA but not n programB. I have a config file with multiple sections and when trying to read each section, it works great...
1
by: James Johnston | last post by:
I've never written a Python program before and I'm trying to read a config file with file path/names (eg. c:\\python24\\*.dll, ... *.exe) to create an output file of filename + md5 values. I'm...
2
by: forest demon | last post by:
I need to be able to create an appender to direct output to a MessageBox. The API does not have a MessageBox appender like nLog does. What would be the easiest way to do this. The examples...
4
by: Ronald S. Cook | last post by:
Currently (manually), I 1) open a Windows SDK Command Prompt and 2) navigate to a particular folder. Then I 3) type a command and press enter. The command is irrelevant (WCF-related) but here it...
2
by: Christian Muggli | last post by:
can someone explain me how to create a app.config file during runtime? i see two ways: - add a skeleton of an app.config file to the exe/dll and extract it during runtime as a resource and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.