Check for definedness of $opts{o} before using it
authorChip Black <bytex64@bytex64.net>
Mon, 23 Jun 2008 06:04:38 +0000 (01:04 -0500)
committerChip Black <bytex64@bytex64.net>
Mon, 23 Jun 2008 06:04:38 +0000 (01:04 -0500)
conv.pl

diff --git a/conv.pl b/conv.pl
index 6180d0f..2378828 100755 (executable)
--- a/conv.pl
+++ b/conv.pl
@@ -13,16 +13,18 @@ my %opts = (
 getopts('vnsj:f:o:i:', \%opts);
 
 my $dirout;
 getopts('vnsj:f:o:i:', \%opts);
 
 my $dirout;
-if (-d $opts{o}) {
-    # output is a directory
-    $dirout = 1;
-} else {
-    # output is a single file, imply -i <ext> unless -i has also been specified
-    if ($opts{o} =~ /\.(\w+)$/) {
-        $opts{i} = $1 unless exists $opts{i};
+if (defined $opts{o}) {
+    if (-d $opts{o}) {
+        # output is a directory
+        $dirout = 1;
     } else {
     } else {
-        print "Specified -o <file>, but '$opts{o}' has no extension.\n";
-        exit 1;
+        # output is a single file, imply -i <ext> unless -i has also been specified
+        if ($opts{o} =~ /\.(\w+)$/) {
+            $opts{i} = $1 unless exists $opts{i};
+        } else {
+            print "Specified -o <file>, but '$opts{o}' has no extension.\n";
+            exit 1;
+        }
     }
 }
 
     }
 }