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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.