From: Chip Black Date: Mon, 23 Jun 2008 06:04:38 +0000 (-0500) Subject: Check for definedness of $opts{o} before using it X-Git-Url: http://git.bytex64.net/?p=conv.git;a=commitdiff_plain;h=f3ee86fe378b5f0f8e0d1391e72f3a3bfca83bea Check for definedness of $opts{o} before using it --- diff --git a/conv.pl b/conv.pl index 6180d0f..2378828 100755 --- 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 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 , but '$opts{o}' has no extension.\n"; - exit 1; + # output is a single file, imply -i unless -i has also been specified + if ($opts{o} =~ /\.(\w+)$/) { + $opts{i} = $1 unless exists $opts{i}; + } else { + print "Specified -o , but '$opts{o}' has no extension.\n"; + exit 1; + } } }