RE: Questions on porting Perl from Unix to Windows

2008-01-24 Thread Andy_Bach
It's a windows cmd.exe thing.  Only dbl quotes work for "-e" script 
creation and there are a number of other issues.  In general, one-liners 
in cmd.exe aren't going to be very useful.  You can get a different shell 
(even bash) for winx but 

a

Andy Bach
Systems Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738  FAX 264-5932

"The Microsoft Exchange Information Store service depends on
the Microsoft Exchange Directory service which failed to
start because of the following error:
The operation completed successfully."
(actual MSE error msg)

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Questions on porting Perl from Unix to Windows

2008-01-24 Thread Andy_Bach
OS is found via the $^O ("carrot capital O") special var:
$ perl -e 'print $^O'
linux

I think winx stuff starts w/ "MS"
C:\>perl -e "print $^O"
MSWin32

but you don't really want to do that. File::Copy
$ perldoc File::Copy
use File::Copy;

   copy("file1","file2") or die "Copy failed: $!";
   copy("Copy.pm",\*STDOUT);
   move("/dev1/fileA","/dev2/fileB");

does it OS-independently.  Using the perl native opendir/readdir commands
perldoc -f readdir
...
opendir(DIR, $some_dir) ΓΆΓΆ die "can't opendir $some_dir: $!";
   @dots = grep { /^\./ && -f "$some_dir/$_" } 
readdir(DIR);
   closedir DIR;

again does this w/o needing to know which OS you're on. You may also want 
to look at:
NAME
   File::Spec - portably perform operations on file names

as for the 2nd question/shebang lines - yeah MS doesn't use the shebang, 
it uses file extension. However perl does use the shebang, even on winx so 
you can just have a shebang of
#!perl -w

and get the warnings etc enabled.  We used to just make a matching batch 
file  that called perl on the script.

a

Andy Bach
Systems Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738  FAX 264-5932

"The Microsoft Exchange Information Store service depends on
the Microsoft Exchange Directory service which failed to
start because of the following error:
The operation completed successfully."
(actual MSE error msg)

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Questions on porting Perl from Unix to Windows

2008-01-24 Thread William . Hoopes
Readdir and file::copy?

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Gary Yang
Sent: Thursday, January 24, 2008 2:16 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Questions on porting Perl from Unix to Windows

 

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.
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Questions on porting Perl from Unix to Windows

2008-01-24 Thread Gary Yang
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.___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs