Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Turning a questionable string into a number

by haukex (Archbishop)
on Jun 29, 2017 at 19:53 UTC ( [id://1193867]=note: print w/replies, xml ) Need Help??


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

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!)

Replies are listed 'Best First'.
Re^4: Turning a questionable string into a number
by choroba (Cardinal) on Jun 29, 2017 at 20:00 UTC
    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,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1193867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found