in reply to Script ignoring while loop on Mountain Lion and Mavericks

it only takes the first line of input, as if it is ignoring the while loop

Nope, your file only contains one line :)

You can use

use Path::Tiny qw/ path /; dd( path( shift )->slurp_raw ); sub dd { use Data::Dumper; print Data::Dumper->new([@_])->Sortkeys(1) ->Indent(1)->Useqq(1)->Dump . "\n"; }
to find out what kind of line endings your files are in, then you can set $/ appropriately and there will be more than one line to read

Your other alternative is to readline n-bytes at a time, see perlvar#$/

  • Comment on Re: Script ignoring while loop on Mountain Lion and Mavericks (newline)
  • Download Code

Replies are listed 'Best First'.
Re^2: Script ignoring while loop on Mountain Lion and Mavericks (newline)
by maklujkar (Initiate) on Feb 13, 2014 at 02:45 UTC
    Thank you for taking the time to reply. It has been several years since I had to write anything in Perl, so I have no idea how to apply the code that you provided. However, because you pointed me in the direction of the line endings, I tried a simpleton's approach to find out what they were. I turned on the "Show Invisibles" option in TextWrangler, where I had created the table as a .txt file after pasting entries from Excel. The lines all ended in the faucet-shaped character. (Sorry, I've forgotten what that's called.) Then I ran the script again, and it worked perfectly. I don't know why showing the line endings makes a difference, but I'll take it. I guess my script used to work because I would paste from the older version of Excel into TextWrangler, but when I had to switch to the new Excel for Mavericks, the line endings disappeared. Thanks again, and good night!