I am a student and enrolled Unix programing this semester. There are two questions relating to perl I can not work out in the last exam ( Actually I have write out my code, however the exam system marked it as "wrong"). Please help me to point out the fault. Thanks.
QUESTION 1 Write a perl script called perl_has_number.pl which takes one argument which is any string. The script should output "true" if the string contains any digits, and "false" otherwise. MY CODE: #!/usr/bin/perl -w if ($ARGV[0]=~ /\d+/) { print "true\n"; } else { print "false\n"; } QUESTION 2 Write a perl script called perl_digits.pl which takes any number of arguments. The script should return the number found by deleting all non-digits. Example: "./perl_digits.pl and1 pan2d 30rr and 4" will return 12304 MY CODE: #!/usr/bin/perl -w sub outcom { $outcome=""; foreach $a (@ARGV) { if ($a=~/\d+/) { $outcome=$outcome.$&; } } return $outcome; } $digital=outcom(@ARGV); print $digital . "\n"; In my view, both code could give out right results. Could you help me to find the fault? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/