G'day maklujkar,
Welcome to the monastery.
"... please e-mail me at ..."
Please don't request responses be sent to your email address: they should be posted here. This is because:
Please remove the email request from your post. (If you don't know how to do this, see "How do I change/delete my post?".)
On to your question. I have Lion (Mac OS X 10.7.5), not Mountain Lion: there may be minor differences but the basic information I've provided should still be valid.
Apple provides a version of Perl (with its own patches) for use with Mac OS X: this is referred to as the System Perl. When you update Mac OS X, the System Perl may change which could affect your code; when you modify the System Perl (e.g. update a module) this could affect Mac OS X functionality. For these reasons, it is generally a bad idea to use the System Perl and a much better idea to install your own version(s) of Perl for your own use.
Your script starts with the shebang line "#!/usr/bin/perl": this says "Use the System Perl". I start all my scripts with "#!/usr/bin/env perl": this says "Use my current version of Perl". I recommend you do this also.
Telling us about the output of 'perl -v' is not all that helpful because we don't know which perl that is. From the commandline, 'which perl' will tell you this. Using the output from that, '/path/to/perl -v' will tell you its version (e.g. '/usr/bin/perl -v' will give you the version of the System Perl). The command 'perlbrew list' will tell you about all the Perls you have: this will not be limited to those installed via perlbrew but will also include the System Perl (/usr/bin/perl) and any others you might have, e.g. MacPorts Perl (/opt/local/bin/perl). [Also note that Perl versions are reported with three numbers (e.g. 5.8.8 or 5.18.2) — you should tell us the full version number as it oftens makes a difference (sometimes a big difference, e.g. there were substantial changes between 5.10.0 and 5.10.1).]
"The perl -v command told me that I was running Perl 5.16. I deleted xcode and everything in the Perl folder in the Library (versions 5.8, 5.12) and any other Perl folder I could find, ..."
You may have caused some serious damage doing this. My System Perl is 5.12.3; what's yours? — you may need to [find out how to] restore it. While there are alternatives to perlbrew, that's what I use and I have six different versions of Perl installed: 'perlbrew switch' allows you to choose whichever version you want. There's also a perlbrew uninstall command: I haven't used it but suspect it would be preferable to flailing around with rm. :-) [Note: it sounds like you'll also need to reinstall xcode.]
When you've got your Perl issues sorted out, your script may run as expected. Without knowing what your input is, I can't really tell you if you're getting the correct output. Try adding print statements to see exactly what data you're reading and which branches of your conditional statements are being executed.
-- Ken
In reply to Re: Script ignoring while loop on Mountain Lion and Mavericks
by kcott
in thread Script ignoring while loop on Mountain Lion and Mavericks
by maklujkar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |