![]() |
Paths in Perl
Different Operating Systems use different characters as their path separator when specifying directory and file paths:
foo/bar/baz # *nix uses a / foo\bar\baz # Win32 uses a \ foo:bar:baz # Mac OS 9 uses a : foo/bar/baz # Mac OS X uses a / (usually!) In Perl you can generally just use a / as your path separator (except on Mac OS 9, thanks Hanamaki). Why? Because Perl will automagically convert the / to the correct path separator for the system it is running on! This means that coding Windows paths like this $path = "\\foo\\bar\\baz"; is not required. You can just use this: $path = "/foo/bar/baz"; and things will be fine. In fact using \\ can be problematic, but you probably already know that :-) If you want to display the expected system delimiter to a user (ie hide the fact that you are using / internally) you can just do something like this: Code: PERL
Code: PERL
|
| All times are GMT +5.5. The time now is 10:43. |