#!/usr/bin/perl # The configuration file is only about 400 lines, # so I Tie::file to @config_file my @config_file; sub procTerm { my $change = $_[0]; my $conf_file = $_[1]; foreach my $line (@$conf_file) { if ($line =~ m/^\s*terminal\s=\s"([^"]+)"\s*$/) { $line =~ s/$1/$change/; } } } sub changeTerm { my $conf_file = shift; print "Change Terminal: "; chomp (my $newTerm = ); procTerm($newTerm, $conf_file); } sub getTags { my $conf_file = shift; my @tags; foreach my $line (@$conf_file) { if ($line =~ m/^\s*names\s=\s{(\s*(.+),?)+\s*/) { @tags = split ",", $line; @tags = map { if ($_ =~ m/"([^"]+)"/) {$_ = $1} elsif ($_ =~ m/([^\s]+)/) {$_ = $1} } @tags; } } print Dumper \@tags; } changeTerm(\@config_file); getTags(\@config_file);