Skip to content

Instantly share code, notes, and snippets.

@Freeaqingme
Created June 15, 2013 00:53
Show Gist options
  • Save Freeaqingme/5786299 to your computer and use it in GitHub Desktop.
Save Freeaqingme/5786299 to your computer and use it in GitHub Desktop.
if(open $etchandle, $etcfile)
{
foreach my $line (<$etchandle>)
{
$line ||= "";
$line =~ s/\#.*//g;
$line =~ s/\s+$//g;
$line =~ s/^\s+//g;
next unless $line;
next if $line =~ /^\-[dh]/;
if($line =~ /^[^\-]/)
{
my ($directive, $arg) = $line =~ /^(.*?)\s+(.*)/;
$conf_directives->{$directive}->($arg);
next;
}
push @$params, $line;
}
}else{
$params = [];
}
($userArg) = "-u root";
if (grep "-u", @$params)
{
$userArg = @$params[grep(/^-u/, @$params)];
# $userArg = grep(/^-u/, @$params);
}
print STDOUT "Some value: $userArg";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment