[Tilesathome] Or/p and Windows?

Henry Loenwind henry at loenwind.info
Sun May 25 22:56:03 BST 2008


Juergen Buchner wrote:

> the reason for the error seems to be the following lines:
> # if data file given in rule file, prepend rule file's path

> Here "/" is assumed to be the directory separator, which is wrong if
> or/p is running under Windows. When adding the lines to

Better:

  if ($rule_file =~ m!(.*)[/\\](.*)! && defined($data))
  {
      $data = $1.'/'.$data;
  }

> it works with Windows. Since I'm not an expert Perl programmer I'm not
> sure if this is the preferred way to implement this platform
> independent ...

I think the File::Spec module is the right way, but as long as we are 
only targeting *nix (including Linux, OS X, etc) and Windows and not 
some more obscure operation systems (Mac OS 9, VMS etc), the [/\\] in 
the regex is enough.

BTW: Windows understands "/" as path separator, too. It's just that some 
Windows programs are more picky. Including cmd.exe, sadly.

cu
Henry

PS: I'd even recommend to write the regex as m!^(.*)[/\\]!, or even 
m!^(.*)[/\\][^/\\]+$!, to be cleaner.




More information about the Tilesathome mailing list