Wish Setup would accept my Perl

Andrew DeFaria Andrew@DeFaria.com
Sat Dec 8 04:03:00 GMT 2007


Michael Kairys wrote:
> Well, I gave it a try, and I can see that ain't gonna happen :)
It might take more effort than just installing Cygwin's Perl.
> I reran setup and let it install perl and whatever else it wanted to 
> (so I now have ruby and phython as well); then I began running scripts 
> under both perls. I quickly realized AS perl exec's cmd.exe whilst 
> Cygwin perl exec's sh, so much of my system and backquote constructs 
> broke.
Well that tells you that your previous invocations of system and 
backquote constructs were not portable to start with. It would be far 
better to centralize such things to a subroutine to try to mitigate the 
portability issues. Then again if you are gonna call programs that just 
don't exist on anything but Windows you will have a problem. But perhaps 
you can do it in a more "posix" way. And if all else fails you can call 
the cmd built in with "cmd /c <command>". Note however that even cmd 
didn't exist on (what?) Win95 or whatever...

So here's an example. Don't call "rd <directory>" call "rm -rf 
<directory>". What I hear you say? That's particular to posix and you'll 
have to have Cygwin installed. Well yes you will, but such code will 
port with no problems to Unix should that need arise and well, you have 
Cygwin installed! Or perhaps code it in Perl as a recursive procedure 
with unlinks, etc.

That message here is writing portable code takes effort (and is not 
always doable...)
> I also noticed that ENV{PATH} and ENV{HOME} return Windows or Unix 
> syntax paths, depending. The Cygwin perl builtins like chdir and chmod 
> were quite happy with Windows paths, as I would expect.
Again, here, knowing your environment and acting accordingly can help. 
You could code things to sense you're on Windows and under Cygwin and 
need to call cygpath to get things normalized...
> As an aside, there seems to be something broken in my installation re. 
> Tk (or perhaps I'm missing something). If I run a script containing 
> (only) "use Tk" I get: Can't load 
> '/usr/lib/perl5/vendor_perl/5.8/cygwin/auto/Tk/Tk.dll' for module Tk: 
> No such file or directory at /usr/lib/perl5/5.8/cygwin/DynaLoader.pm 
> line 230.
>
> ... however /usr/lib/perl5/vendor_perl/5.8/cygwin/auto/Tk/Tk.dll is in 
> fact there.
Not sure about that but you do realize that Perl::Tk will only run with 
a running X server...
> So given that I "should" keep Cygwin perl around (meaning that someday 
> I'm likely to regret it if I don't :) and that I'm going to keep AS 
> perl as well, I need to find the best way for them to coexist. I think 
> the suggestion made elsewhere in this thread (sorry, I forget who made 
> it) that I forego "perl -S" in favor of shebang is good; I find that 
> #!/local/perl/bin/perl finds my AS perl (which is in D:\Local\Perl, 
> and D:\Local is mounted on /local). ASsuming Cygwin correctly shebangs 
> any scripts it needs to use, I can remove AS perl from my Cygwin path 
> (as set in .bashrc) but leave it in my Windows path (as set via the 
> Control Panel) and as I understand it to date, everything should work. 
> If I don't in fact understand it (not unlikely :) please advise.
Personally I'm of the school of making everything much more like Linux. 
This means assuming Cygwin is installed (or installing it) using posix 
paths and the like and coding things to sense whether I'm in Windows 
under Cygwin or Linux. I find that my code better ports to Linux and I 
do port my code there. This may not be a concern for you, however, I 
don't see many Windows emulating environments for Linux but I do see a 
find Linux like environment for Windows in Cygwin. YMMV.
> But given my "programmer's OCD" I will probably keep poking at why my 
> AS scripts don't run on Cygwin perl, so any advice about setting it 
> up, why Tk doesn't work, etc. would be appreciated (as are all your 
> comments).
As I said I don't know exactly why your Tk isn't working. I do know that 
Tk under Cygwin assumes a running X server. I rarely run an X server - I 
simply use rxvt instead - so I don't like that requirement. I also work 
with IBM/Rational products and often need to run ccperl or cqperl - both 
of which are AS based. And they have Tk in there that works straight on 
Windows (like rxvt does if it senses there is no X server running - I 
wish Cygwin's Perl::Tk would do that!).
-- 
Andrew DeFaria <http://defaria.com>
Everybody repeat after me ...We are all individuals.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list