CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Getopt::Std options paring problems in windows

 



sonderkar
New User

Apr 13, 2010, 1:35 AM

Post #1 of 3 (2046 views)
Getopt::Std options paring problems in windows Can't Post

Hi,
I have A LOT of scripts, and I'm now trying to put them all in 1 directory on a windows 64 bit machine, at put this directory in the system PATH variable, so the scripts can be executed from the command line without the script having to be in the same directory. Most if working fine, but I have some where I use the
Getopt::Std option.
These options are not parsed. these are parsed using Linux

Does anybody know a fix to this for windows?

use strict;
use Getopt::Std;
use vars (qw " $opt_i $opt_l");

getopts('i:l:');
print "Usage:\n-i inputfile\n-l Number of lines in small file\n" unless @ARGV;
exit unless @ARGV;



my $Inputfile = $opt_i;
my $MaxLinecount = $opt_l ? $opt_l: 1000;
my $Outputfile = "Small-".$Inputfile;
my $Linecount = 0;
print "$MaxLinecount\n";


open( fhIN, "$Inputfile" || die "Can't open $Inputfile" );
open( fhOUT, ">$Outputfile" || die "Can't open $Outputfile" );
while (<fhIN>) {

my $line = $_;
chomp $line;
$Linecount++;
print fhOUT "$line\n";
last if $Linecount == $MaxLinecount;

}
close(fhIN);
close(fhOUT);

Code



      
    


FishMonger
Veteran / Moderator

Apr 13, 2010, 5:07 AM

Post #2 of 3 (2041 views)
Re: [sonderkar] Getopt::Std options paring problems in windows [In reply to] Can't Post

Sounds like your .PL file type association is not setup correctly.

The action attribute needs to be set like this (adjust the path as needed):

Quote
"C:\Perl\bin\perl.exe" "%1" %*



sonderkar
New User

Apr 13, 2010, 6:25 AM

Post #3 of 3 (2038 views)
Re: [FishMonger] Getopt::Std options paring problems in windows [In reply to] Can't Post

I believe you could be right,
i looked an it seems that this is already set with the%*

I found a thread where people had the same problem:

Quote
http://community.activestate.com/forum-topic/problem-passing-arguments


BUT I made it work. Can't explain it, but using windows powershell it works Smile

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives