My testing code:
Test runs:
Qustions:
1) How come that a question mark becomes a letter 'a'?
2) what is the correct implementation to treat a double quote " & a single quote ' as a plain character in cmdline?
Thanks!
Code:
if($ARGV[0] eq "\?" || $ARGV[0] eq "?" || $ARGV[0] eq '\?' || $ARGV[0] eq '?') {
&usage;
}
elsif($ARGV[0] eq "\'" || $ARGV[0] eq "'" || $ARGV[0] eq '\'' ||
$ARGV[0] eq '\"' || $ARGV[0] eq '"' || $ARGV[0] eq '\"') {
print "Invalid char passed in from cmdline: #$ARGV[0]#\n";
}
else {
print "==-->>\$ARGV[0] = #$ARGV[0]#\n";
}
exit;
sub usage {
print "In usage().\n";
exit;
}
Test runs:
Code:
[Linux|bash] 50 => ./a.pl ?
==-->>$ARGV[0] = #a#
[Linux|bash] 51 => ./a.pl '
>
[Linux|bash] 51 => ./a.pl "
>
Qustions:
1) How come that a question mark becomes a letter 'a'?
2) what is the correct implementation to treat a double quote " & a single quote ' as a plain character in cmdline?
Thanks!