Ugh.

Once again, I write up another response without completely reading  
what you're trying to do.

Instead of determining the OS and then using backticks to execute  
shell/OS specific commands, why don't you use OS independent libraries  
to manipulate files and directories?  Check out File::Copy or the Perl  
builtins opendir and readdir (use DirHandle for a more OOP way to do  
it).  Or you could use "ExtUtils::Command" and keep only the unix  
style commands.

Thanks,
Charles Alderman



Quoting Charles Alderman <[EMAIL PROTECTED]>:

> http://perldoc.perl.org/perlvar.html#$OSNAME
>
> $^O or "use English" and $OSNAME will tell you a little more than what
> you're trying to do.  What you're trying kind of reminds me of how
> Javascript'ers figure out the browser or XHR call they need.
>
> As far as the shebang line (#!...), you're right, that doesn't work in
> Windows.  But, you can always run your Perl code from the command line
> by explicitly calling perl.  Example: "%> perl myscript.pl".  That
> works no matter the OS you're using.
>
> Under Windows, you can optionally associate files with .pl extensions
> with the perl.exe executable.  That shouldn't be too hard to figure out
> in your windows explorer: just double click a .pl file.  Windows
> associations also work from the command line.  Although, if you're
> running your scripts as cgi scripts under apache on Windows, you can do
> both the shebang line or windows file extension associations.  Just
> check out your apache configuration file....
>
> Just to let you know, your question was posted to mailing list for the
> Win32-GUI module, so it wasn't really topical for this mailing list.
> If you have any other questions regarding running Perl under windows or
> unix, they would be better addressed in a different mailing list.
> Activestate hosts a bunch like perl-win32-users or perl-unix-users.
> See: http://aspn.activestate.com/ASPN/Perl/Mail/
>
> Thanks,
> Charles Alderman
>
> Quoting Gary Yang <[EMAIL PROTECTED]>:
>
>> Hi All,
>>
>>  I need to port my Perl script from Unix to Windows. Can someone    
>> tell me how to figure out which platform I am on? i.e. I need to    
>> know which Perl command can help me determin the platform. Once I    
>> know the platform, I'll code my script as the example bellow. But,   
>>  how to figure out I am on Windows or Unix?
>>
>>  if ($usingUNIX)
>>    {
>>    $directory = `ls`;   #UNIX version.
>>    $copyCommand = `cp`;   #UNIX version.
>>    }
>> else
>>    {
>>    $directory = `dir`;  #Win32 version.
>>    $copyCommand = `COPY`;  #Win32 version.
>>    }
>>
>>
>>  Second question:
>>  The UNIX #!/usr/bin/perl notation does not work with Perl scripts   
>>  on Windows. How should I code if it is Unix I place    
>> "#!/usr/bin/perl" at the very first line of the script? But, I do    
>> not place it at the first line of code if it is not Unix? How   
>> should  I do it?
>>
>>  Your answers are greatly appreciated.
>>
>>
>>  Thanks,
>>
>>
>>  Gary
>>
>>
>>
>>
>> ---------------------------------
>> Looking for last minute shopping deals?  Find them fast with Yahoo! Search.




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to