Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Perl / FileFind or ...

by Anonymous Monk
on Nov 27, 2012 at 22:51 UTC ( #1005938=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl / FileFind or ...
in thread Perl / FileFind or ...

Yea Tom, that be exactly the issue.

Since PerlMonks offers threaded discussions, it is important to reply to the correct node by clicking the [reply] alongside the node of interest

Guess I just don't get it, Why such a simple thing is so difficult.

Decode the input, Encode the output, read perlunitut: Unicode in Perl#I/O flow (the actual 5 minute tutorial) and learn about your shell

$ chcp Active code page: 437 $ echo > "da-MötleyCrüe" $ dir /b "da-*" da-MötleyCrüe $ dir /b "da-*" | perl -MData::Dump -e " dd[<>] " ["da-M\x94tleyCr\x81e\n"] $ perl -MData::Dump -e " dd[ glob q/da-*/ ] " ["da-M\xF6tleyCr\xFCe"]

Single byte encoding can be hard to guess

$ perl -MEncode::Detective=detect -le " die detect( glob q/da-*/ ) " windows-1252 at -e line 1. $ perl -MEncode::Guess -e " die guess_encoding( glob q/da-*/ ) " No appropriate encodings found! at -e line 1. $ dir /b "da-*" | perl -MEncode::Detective=detect -e " $f = <>; die de +tect($f ) " Died at -e line 1, <> line 1. $ dir /b "da-*" | perl -MEncode::Guess -e " $f = <>; die guess_encodin +g($f ) " No appropriate encodings found! at -e line 1, <> line 1. $ dir /b "da-*" | perl -MEncode::Guess -e " $f = <>; die guess_encodin +g($f , q/cp437/) " Encode::XS=SCALAR(0x9a622c) $ dir /b "da-*" | perl -MEncode::Guess -e " $f = <>; die guess_encodin +g($f , q/cp437/)->name " cp437 at -e line 1, <> line 1.

But once you know, just binmode
$ perl -le " print for glob q/da-*/ "
da-M÷tleyCrⁿe

$ perl -le " binmode STDOUT , q/:encoding(cp437)/; print for glob q/da-*/ "
da-MötleyCrüe

$ perl -Mopen=:std,encoding(cp437) -le " print for glob q/da-*/ "
da-MötleyCrüe

$ perl -MEncode::Locale -le " binmode STDOUT, q{encoding(console_out)}; print for glob q/da-*/ "
da-MötleyCrüe


Comment on Re^2: Perl / FileFind or ...
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2014-09-23 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (241 votes), past polls