trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1103842 - /trafficserver/traffic/trunk/contrib/perl/ConfigMgmt/lib/Apache/TS/Config/Records.pm
Date Mon, 16 May 2011 18:58:11 GMT
Author: zwoop
Date: Mon May 16 18:58:11 2011
New Revision: 1103842

URL: http://svn.apache.org/viewvc?rev=1103842&view=rev
Log:
Minor fixes.

Modified:
    trafficserver/traffic/trunk/contrib/perl/ConfigMgmt/lib/Apache/TS/Config/Records.pm

Modified: trafficserver/traffic/trunk/contrib/perl/ConfigMgmt/lib/Apache/TS/Config/Records.pm
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/contrib/perl/ConfigMgmt/lib/Apache/TS/Config/Records.pm?rev=1103842&r1=1103841&r2=1103842&view=diff
==============================================================================
--- trafficserver/traffic/trunk/contrib/perl/ConfigMgmt/lib/Apache/TS/Config/Records.pm (original)
+++ trafficserver/traffic/trunk/contrib/perl/ConfigMgmt/lib/Apache/TS/Config/Records.pm Mon
May 16 18:58:11 2011
@@ -61,9 +61,12 @@ use constant {
 sub new {
     my ($class, %args) = @_;
     my $self = {};
-    my $f = $args{file} || $args{filename} ||  "-";
+    my $fn = $args{file};
 
-    $self->{_filename} = $f;  # Filename to open when loading and saving
+    $fn = $args{filename} unless defined($fn);
+    $fn = "-" unless defined($fn);
+
+    $self->{_filename} = $fn;  # Filename to open when loading and saving
     $self->{_configs} = [];            # Storage, and to to preserve order
     $self->{_lookup} = {};             # For faster lookup, indexes into the above
     $self->{_ix} = -1;                 # Empty
@@ -81,9 +84,12 @@ sub new {
 sub load {
     my $self = shift;
     my %args = @_;
-    my $filename = $args{filename} || $self->{_filename} || die "Need a filename to load";
+    my $fn = $args{file};
+
+    $fn = $args{filename} unless defined($fn);
+    $fn = $self->{_filename} unless defined($fn);
 
-    open(FH, "<$filename");
+    open(FH, "<$fn");
     while (<FH>) {
         chomp;
         my @p = split(/\s+/, $_, 4);
@@ -111,7 +117,9 @@ sub load {
 sub get {
     my $self = shift;
     my %args = @_;
-    my $c = $args{conf} || $args{config};
+    my $c = $args{conf};
+
+    $c = $args{config} unless defined($c);
     my $ix = $self->{_lookup}->{$c};
 
     return [] unless defined($ix);
@@ -125,8 +133,12 @@ sub get {
 sub set {
     my $self = shift;
     my %args = @_;
-    my $c = $args{conf} || $args{config} || $_[0];
-    my $v = $args{val} || $args{value} || $_[1];
+    my $c = $args{conf};
+    my $v = $args{val};
+
+    $c = $args{config} unless defined($c);
+    $v = $args{value} unless defined($v);
+
     my $ix = $self->{_lookup}->{$c};
 
     if (!defined($ix)) {
@@ -147,7 +159,9 @@ sub set {
 sub remove {
     my $self = shift;
     my %args = @_;
-    my $c = $args{conf} || $args{config};
+    my $c = $args{conf};
+
+    $c = $args{config} unless defined($c);
 
     my $ix = $self->{_lookup}->{$c};
 
@@ -185,11 +199,14 @@ sub append {
 sub write {
     my $self = shift;
     my %args = @_;
-    my $filename = $args{file} || $args{filename} || "-";
+    my $fn = $args{file};
+
+    $fn = $args{filename} unless defined($fn);
+    $fn = "-" unless defined($fn);
 
-    if ($filename ne "-") {
+    if ($fn ne "-") {
         close(STDOUT);
-        open(STDOUT, ">$filename") || die "Can't open $filename for writing";
+        open(STDOUT, ">$fn") || die "Can't open $fn for writing";
     }
 
     foreach (@{$self->{_configs}}) {



Mime
View raw message