Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Cross-platform accented character file names sorting

by Athanasius (Archbishop)
on May 19, 2015 at 16:34 UTC ( [id://1127152]=note: print w/replies, xml ) Need Help??


in reply to Cross-platform accented character file names sorting

Hello perlimpinpin, and welcome to the Monastery!

use Config; use utf8::all if $Config{osname} eq 'Linux'; # perl adamantly ignores +the condition

You can’t use Perl’s usual if here, you must use the pragma if, which has a different syntax:

use Config; use if $Config{osname} eq 'Linux', 'utf8::all';

Note also that the Config module isn’t needed for this test. Either $ENV{OS} or $^O will give you the information you need.

Update 1: Struck out $ENV{OS}, thanks to afoken, below.

Update 2: Changed utf8::all to 'utf8::all' (i.e., added quotes) to avoid a syntax error when the condition fails.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Cross-platform accented character file names sorting
by afoken (Chancellor) on May 19, 2015 at 18:58 UTC
    Note also that the Config module isn’t needed for this test. Either $ENV{OS} or $^O will give you the information you need.

    $ENV{OS} is specific for Windows (I think NT and following, never saw it on 3.x or 9x), it is not set on Linux. A malicious user could set it to any nonsense value. Try to avoid that.

    $^O is reliable, returning MSWin32 for each and every Windows version (except perhaps Windows CE / Mobile), including 64 bit variants. After checking $^O eq 'MSWin32', the type (NT-based or DOS-based) and the exact version can be checked using Win32::IsWinNT(), Win32::IsWin95(), Win32::GetOSVersion(), Win32::GetOSName(), and Win32::GetOSDisplayName(). All of these functions are documented in Win32, those marked with [CORE] are built into the perl executable and are available without loading the Win32 module.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

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

    No recent polls found