Re: How do I migrate a set of Unix scripts to Windows ActivePerl?
by OeufMayo (Curate) on Mar 24, 2001 at 00:55 UTC
|
Perl is usually smart enough to do what you mean and internally convert slashes to backslashes when you're using file paths (or colons for Mac).
There shouldn't be any trouble migrating from one platform to one other, provided the modules are properly compiled for the target platform.
<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>
| [reply] |
Re: How do I migrate a set of Unix scripts to Windows ActivePERL?
by arturo (Vicar) on Mar 24, 2001 at 00:40 UTC
|
For any modules installed into the @INC directories (including all standard modules), there should be no migration problem whatsoever. For any modules you've put in other places, there's really nothing for it but to find all the use lib statements and convert 'em. Fortunately for you, there's this programming language that's pretty good at that sort of thing ... =)
One way: First decide where you're going to put your libraries on the Unix-type system. Use a hash as a translation table, where the keys are windows directories and the values are your *nix correlates of those directories. That should make writing a script that updates all your perl scripts.
| [reply] [d/l] [select] |
Re: How do I migrate a set of Unix scripts to Windows ActivePERL?
by Anonymous Monk on Mar 24, 2001 at 03:58 UTC
|
Under windows you can access files with the full path by using two backslashes instead of a single backslash in your path -
For example C:\Perl\lib would become C:\\Perl\\lib.
| [reply] |
Re: How do I migrate a set of Unix scripts to Windows ActivePERL?
by voyager (Friar) on Mar 24, 2001 at 06:24 UTC
|
As one of the others said, it's not that hard unless something else is broken:
use lib 'c:/some/perl/lib';
works fine. And if the directories are on hte same drive, you can leave off the directory:
use lib '/some/perl/lib';
And as another noted, slashes either way are fine tho' you need to be careful within double quotes.
| [reply] [d/l] [select] |
|
|
You only need to be careful in double quotes? What does
this short program do?
my $dir = 'c:\this\is\a\dir\';
print "$dir\n";
| [reply] [d/l] |
|
|
It complains that the string is not terminated. Touche (accent is assumed). So use forward slashes, even on windows and avoid that mess? :)
| [reply] |
|
|
Re: How do I migrate a set of Unix scripts to Windows ActivePERL?
by Rudif (Hermit) on Mar 24, 2001 at 23:23 UTC
|
Don't forget the environment variable PERL5LIB.
On a Win2k machine, I added to @INC a directory where I keep some local modules, H:\devperl\tools, by setting this variable via the Windoze Control Panel. This way I don't need any use lib statements in scripts.
C:\>set
PERL5LIB=H:\devperl\tools;
C:\>perl -e"print qq( @INC )"
H:\devperl\tools C:/Perl/lib C:/Perl/site/lib .
HTH
Rudif
P.S. If you are using taint checks, PER5LIB is ignored, and you have to resort to use lib statements in scripts.
See perlrun.
PPS.
However, Windows uses the backslash, not the forward slash.
AFAIK, Perl is equally happy with either kind of slash on Windoze, even both kinds in the same path:
print "yes dir\n" if -d "c:\\perl/lib";
print "yes dir\n" if -d 'c:\perl/lib';
You have to use backslashes only if you feed the path to a Windoze command, for example
system "dir c:\\perl\\lib";
| [reply] [d/l] [select] |
Re: How do I migrate a set of Unix scripts to Windows ActivePERL?
by satchboost (Scribe) on Mar 28, 2001 at 00:17 UTC
|
Ok. So, I got my directory issues to work. (I futzed, it worked, I'm not complaining.)
Now, the issue is that the '-f' check isn't working. I've perused the documentation and I can't find any reference to why '-f' wouldn't work, but it doesn't and I don't know why.
Help, yet again? | [reply] |
Re: How do I migrate a set of Unix scripts to Windows ActivePERL?
by satchboost (Scribe) on Mar 28, 2001 at 00:17 UTC
|
Ok. So, I got my directory issues to work. (I futzed, it worked, I'm not complaining.)
Now, the issue is that the '-f' check isn't working. I've perused the documentation and I can't find any reference to why '-f' wouldn't work, but it doesn't and I don't know why.
Help, yet again? | [reply] |
|
|
It would help to have the code where it doesn't work.
However as readdir warns, the usual problem is that you
are testing filenames without the directory included.
That is a very, very common error. In fact it is on the
tip of my brain because I made it earlier today... :-)
| [reply] |