Skip to content

Instantly share code, notes, and snippets.

@numberwhun
Created November 28, 2011 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numberwhun/1399639 to your computer and use it in GitHub Desktop.
Save numberwhun/1399639 to your computer and use it in GitHub Desktop.
Process a configuration file
########################################################################################
# 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