Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Backward compatibility: $^O in perl 4

by hawtin (Prior)
on May 08, 2003 at 06:30 UTC ( [id://256480]=note: print w/replies, xml ) Need Help??


in reply to Backward compatibility: $^O in perl 4

I had the same problem and came across a solution that gcc uses. For various reasons this is expressed as a bash script and a more recent version is probably abailable. I leave the conversion to Perl as an exercise for the reader:

# Short circuit this function if we know which system we are on if [ $OS_SYSTEM_REALLY ]; then echo "${OS_SYSTEM_REALLY}" return fi # First get the values for this machine # Code lifted from config.guess in the gcc software OS_UNAME_M=`(uname -m) 2>/dev/null` || OS_UNAME_M=unknown OS_UNAME_S=`(uname -s) 2>/dev/null` || OS_UNAME_S=unknown OS_UNAME_R=`(uname -r) 2>/dev/null` || OS_UNAME_R=unknown OS_UNAME_V=`(uname -v) 2>/dev/null` || OS_UNAME_V=unknown OS_UNAME="${OS_UNAME_M}:${OS_UNAME_S}:${OS_UNAME_R}:${OS_UNAME_V}" # Note: order is significant - the case branches are not exclusive +. case "${OS_UNAME}" in sun4*:SunOS:5.[012345]*:*) echo "sol24" return ;; sun4*:SunOS:5.[6789]*:*) echo "sol26" return ;; sun4*:SunOS:[7891]*:*) echo "Unknown Solaris version" >&2 echo "Try setting \$OS_SYSTEM_REALLY to sol26" >&2 echo "unknown" return ;; sun4*:SunOS:*:*) echo "sun" return ;; *:AIX:1:4) echo "aix41" return ;; *:IRIX*:5.*:*) echo "sgi" return ;; *:IRIX*:6.[2345]:*) echo "irix62" return ;; 9000/[78]??:HP-UX:*:*) echo "hp" return ;; i[345678]86:Linux:*:*) echo "linux" return ;; sparc:Linux:*:*) echo "ulinux" return ;; *:*:*:*) # If we get here then we have something weird echo "Unknown system \"${OS_UNAME}\"" >&2 echo "Try setting \$OS_SYSTEM_REALLY to one of sun, sol, h +p etc" >&2 echo "unknown" return ;; esac

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-03-29 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found