From f3ee86fe378b5f0f8e0d1391e72f3a3bfca83bea Mon Sep 17 00:00:00 2001 From: Chip Black Date: Mon, 23 Jun 2008 01:04:38 -0500 Subject: [PATCH] Check for definedness of $opts{o} before using it --- conv.pl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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; + } } } -- 2.25.1