![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl config file Help | Harikrishna | Shell Programming and Scripting | 2 | 05-21-2008 09:07 PM |
| Perl config file Help | Harikrishna | Shell Programming and Scripting | 5 | 05-19-2008 01:40 AM |
| Extracting data from text file based on configuration set in config file | suparnbector | Shell Programming and Scripting | 3 | 08-09-2007 11:25 PM |
| using config file | mape | Shell Programming and Scripting | 1 | 09-06-2006 10:37 PM |
| Perl CGI to access / edit "root" owned config files | WIntellect | Shell Programming and Scripting | 1 | 04-23-2003 12:48 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Perl config file Help
HI
I have a config file (ip.config)that has the following fields with colon as delimeter. yahoo.com:1919 ( host and port number) rediffmail.com:2020 gmail.com:2121 How to read it in a perl script. I need to parse the host and port number in the perl script using split function ...Please Help |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
plz help |
|
|||
|
here you go:
Code:
#!/usr/bin/perl
# read_config.pl
my $filename = shift;
my %host_info = ();
open (CONF_FILE, '<', $filename) or die "Failed to read file $filename : $!";
while (<CONF_FILE>) {
chomp;
next if (m/^$/); # Skip empty lines
next if (m/^\s*#/); # Skip comments
if (m/^(.*?):(\d+)/) {
$host_info{$1} = $2;
}
}
close (CONF_FILE);
|
|
|||
|
Quote:
HI Yogesh my $filename = shift; my %host_info = (); These two syntax giving error.. How i could give my $filename = shift;???? |