Reputation: 13
"Use of uninitialized value $str1 in string eq at ./script.pl line 20"
not sure why I get this error on line 20, if I comment 20 out, it goes away:
15 ######## HELP section ################
16 #
17 our @ARGV;
18 our ( $str1, $str2 ) = @ARGV;
19
20 if ( $str1 eq "help" ) { &help(); }
21
22 if ( !$str1 ) { &help(); }
23 #
24 sub help {
25 print <<EOF;
26 +++++++++++++++++++++++++++++++++++++++++++++++++++
27 + usage: $0 "cmd1,cmd2,cmd3" "host1,host2,host3"
28 +++++++++++++++++++++++++++++++++++++++++++++++++++
29 EOF
30 exit 0;
31 }
Upvotes: 1
Views: 1855
Reputation: 241808
It's not an error, it's a warning. It means "$str1" is uninitialized, which in this case means there were no command line arguments specified to the script.
Merge lines 20 and 22 into
help() if ! $str1 || $str1 eq 'help';
Upvotes: 2