Easy question - please help?

Ok I'm working on a Windows system but my web-host is Linux. My question is is there a way to determine the default path seperator of the system a script is being run on? I like to keep my scripts as flexible as possible.

Would appreciate any input - thank you.

Tvienti

Comments

  • : Ok I'm working on a Windows system but my web-host is Linux. My
    : question is is there a way to determine the default path seperator
    : of the system a script is being run on? I like to keep my scripts
    : as flexible as possible.
    Hmmmm...not too sure on path seperator, though File::Spec may have something to say on it perhaps - I ain't used it so I don't know.

    You can always look at the contents of the $^O variable.

    perl -e "print $^O;"

    On Windows it prints MSWin32, on Linux it simply prints linux. So you can work out what OS you are on, and if you are on Windows you know that you will need and you might want to assume / as the default for most other situations. There may be a better way though.

    Other question is does it really matter, because I'm quite sure I've used forward slashes in scripts that I have run under Windows, and it's all worked out fine. And if it works...you know the saying. :-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • : Other question is does it really matter, because I'm quite sure I've used forward slashes in scripts that I have run under Windows, and it's all worked out fine. And if it works...you know the saying. :-)
    :
    : Jonathan
    :

    Excellent point - thanks for that :) Rockin' signature too.. hell if I can figure out the logic behind it.
  • : Excellent point - thanks for that :)
    No probs... FYI, File::Spec is kinda related to these kind of issues, I've checked into it. It has functions for cat'ing paths together and it uses the "correct" path seperator depending on the OS as well as other good things. So I guess there are some cases where it does matter. If you're just doing normal file opening, reading, writing and using relative paths, I doubt you'll run into trouble though. I never have.

    : Rockin' signature too.. hell if I can figure out the logic behind it.
    Is that, the logic behind how it works, or the logic behind how my mind somehow thought it up? You've probably got more chance with the first, I'm still not sure about the second... ;-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories