http://qs321.pair.com?node_id=1193866


in reply to Re: Turning a questionable string into a number
in thread Turning a questionable string into a number

Good questions, but the only thing I haven't given you is a self-contained example that you could run. Apologies. However, I just resaved the file out as unicode 8-bit and everything worked just fine. So, problem solved. A big thanks to all who took the time to response.

—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Replies are listed 'Best First'.
Re^3: Turning a questionable string into a number
by haukex (Archbishop) on Jun 29, 2017 at 19:53 UTC
    I just resaved the file out as unicode 8-bit and everything worked just fine.

    Ah yes, Windows does like UTF-16...

    use warnings; use strict; use Encode 'encode'; my $in = "1130\t"; my $str = encode('UTF-16', $in, Encode::FB_CROAK); $str=~s/^\xFE\xFF|\t//g; # remove BOM & tab print $str*1, "\n"; __END__ Argument "\01\01\03\00\0" isn't numeric in multiplication (*) at - lin +e 7. 0

    An alternative for you would also be open($fh, '<:raw:encoding(UTF-16)', 'filetoparse.txt') ... (Updated to add :raw as per choroba's reply, thanks!)

      Also note that on Windows, you need to specify :raw first when specifying a file encoding. See e.g. Re^3: unicode in windows.
      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,