Created
November 28, 2011 08:38
-
-
Save numberwhun/1399639 to your computer and use it in GitHub Desktop.
Process a configuration file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################################## | |
# Process Configuration File | |
# | |
# First, open the file and apply a file handle. | |
# Second, take the next record and store in a variable | |
# Third, chomp to remove the newline | |
# Fourth, split the line on the separator (change if needed) and store in variables | |
######################################################################################## | |
open(CONFIG, "./myfile.config"); | |
$config_record = <CONFIG>; | |
chomp($config_record); | |
($parameter1, $value1) = split(/\s+/, $config_record); | |
$config_record = <CONFIG>; | |
chomp($config_record); | |
($parameter2, $value2) = split(/\s+/, $config_record); | |
$config_record = <CONFIG>; | |
chomp($config_record); | |
($parameter3, $value3) = split(/\s+/, $config_record); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment