Hi,
I have a path which may look like:
UNIX:
---------
PATH=/usr/local/share:/usr/local:...
Where each path is seperated by ":".
Windows:
------------------
PATH=E:\foo:D:\bar
Again the path seperated by ":". ( I cannot change the seperator )
How can i split the path on ":" which gives me correct entries irrespective of whether
i am on windows or unix.
Right now i am trying to do something like:
sub tokens {
my ($path) = @_;
if($OSNAME eq "Win32") {
my @tokens = split(/:/,$path);
my @newtokens;
for (my $i=0;$i<$#tokens;$i++) {
push @newtokens,join(/:/,$tokens[$i],$tokens[$i++]);
}
return @newtokens;
}
return split(/:/,$path);
}
But i am not convinced, this is elegant.
TIA,
-Sharad