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

Re^2: APPerl: "osname=cosmo" problem

by Anonymous Monk
on Jun 30, 2024 at 03:33 UTC ( [id://11160270]=note: print w/replies, xml ) Need Help??


in reply to Re: APPerl: "osname=cosmo" problem
in thread APPerl: "osname=cosmo" problem

    >> However, $^O reported cosmo (presumably short for Cosmopolitan Libc) on all platforms. This will cause problems with modules which provide different functionality based on $^O. File::Spec gave good examples of this.

    > You can get some indication of the system from POSIX::uname(). The docs for this are hedged about with caveats, but if it returns something germaine you can in theory derive an appropriate value from this and assign it to $^O itself, which (believe it or not) can be modified. This modification must be done at compile time, before any of the affected modules are loaded.

Nice trick, thanks!

% perl -le 'print $^O'                                           
darwin

% ./perl.com -le 'print $^O'                                           
cosmo

% ./perl.com -MPOSIX -le 'BEGIN{@_=POSIX::uname;$^O=lc $_[0]}print $^O'                 
darwin

% ./perl.com -le 'BEGIN{$^O="MSWin32"}use File::Spec;print for @File::Spec::ISA'
File::Spec::Win32

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-09-10 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.