commit:f3ee86fe378b5f0f8e0d1391e72f3a3bfca83bea
author:Chip Black
committer:Chip Black
date:Mon Jun 23 01:04:38 2008 -0500
parents:2787fb418e134d9653ed8d8d1de6b31ee7358c8b
Check for definedness of $opts{o} before using it
diff --git a/conv.pl b/conv.pl
line changes: +11/-9
index 6180d0f..2378828
--- a/conv.pl
+++ b/conv.pl
@@ -13,16 +13,18 @@ my %opts = (
 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 {
-        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;
+        }
     }
 }