• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Porting Perl app to Win32

I have an app that I wrote on a UNIX system and am in the process of porting it to a Win32 platform.  For the most part, various scripts seem to work fine.  I am running into a problem when one script calls another script inline like :
@list = `anotherscript.pl cmdlopt1 cmdlopt2`;

This format works fine under Unix but seems to not work at all under Win32.  I have not been able to get scripts to run that take command line options from a dos prompt either.

$ARGV[1] works for Unix but seems to have trouble under Win32.

Has anybody seen a similar problem and know a fix?
0
themask
Asked:
themask
  • 3
  • 2
1 Solution
 
Kim RyanIT ConsultantCommented:
The back tick (`) notation is very old now. You could try this instead:
@list = system("anotherscript.pl cmdlopt1 cmdlopt2");

Ideally, you could turn anotherscript.pl into a module and then you can call any method (subroutine) in that module by the usual sub call approach.

Command line arguments should work fine in Windows. How are you invokong your script? You may have to say:
perl your_script.pl arg1 arg2
To test what gets in, do a print @ARGV as your first line.
0
 
themaskAuthor Commented:
I got both problems fixed by playing around with it.  I had to call the perl interpreter explicity to get it to accept command line options.

I may look at modules in the future, but now I just need to get it functioning for a demo.  We don't plan on releasing a Win32 version currently.

As for the system call, that won't work because the script returns a list of values and the system call only returns the exit status (usually 1 or 0) from the executed application.
0
 
themaskAuthor Commented:
Thanks for the help, although I had it working before I heard from you.
0
 
Kim RyanIT ConsultantCommented:
YEs, perl for windows won't understand the #!/usr/bin/perl in the first line of scripts, so you have to invoke it explicitly.

By using modules to get around the back tick problem, you will make your code much more portable, so it's not really just a Winndows version. You may use other platforms in the future as well.
0
 
themaskAuthor Commented:
The scripts run without calling perl explicitly but they don't accept commandline options.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now