New Perl Programmer
Hello there. I need help debugging a perl program for printing out recipes. Keep in mind, I am extremely new to perl programming. I have probably made some blindingly obvious mistake. Thank you.
Code:
#!/usr/bin/perl |
Try to change every string comparaison == with the perl string comparaison operator: eq
so replace if($pastasel == "acpt") with if($pastasel eq "acpt") etc |
These 2 vars are unused:
my $acptloc = <recipe/acpt.txt>; my $bpcloc = <recipe/bpc.txt>; you should get a warning from Perl about that. Personally, I'd find your var names easier to read if you insert underscores between words eg $recipe_cat_select instead of $recipecatselect, but that's just me ;) You can ask Perl to check your code without executing the prog like this: perl -wc myprog.pl Actually, I think instead of my $acptloc = <recipe/acpt.txt>; you mean my $acptloc = "recipe/acpt.txt"; |
Quote:
|
Quote:
|
Nope, still not working.
|
try add: chomp $recipecatselect;
just under the my $recipecatselect = <STDIN>; line (because $recipecatselect contains a \n character at the end, so could never be strictly equal to "pasta" for example, chomp will remove the \n) |
... and don't just say 'its not working', tell us what error you get etc.
|
All times are GMT -5. The time now is 08:44 PM. |