Solved

Perl does not see command line arguments

Posted on 2014-01-02
10
506 Views
Last Modified: 2014-01-11
I am rehosting my Perl programs from Windows 7 to 8.1.  All is well except that my perl scripts do not detect any command line parameter.  Here is my assoc command

-----------------------------------------------------
 C:\ODpair>assoc .pl
.pl=Perl

C:\ODpair>ftype Perl
Perl="C:\Perl\bin\perl.exe" "%1" %*
-----------------------------------------------------

I appreciate any help to resolve this from you experts.
pax
0
Comment
Question by:cpeters5
  • 6
  • 4
10 Comments
 
LVL 28

Expert Comment

by:FishMonger
ID: 39751476
Having an ftype entry is not required and in my case Perl is not listed in ftype.

What is required is having the proper registry entry under HKEY_CLASSES_ROOT.

Open regedit and navigate to the Perl entry and inspect its layout and value for the command param.  In my case it's actually under HKEY_CLASSES_ROOT\Perl_program_file.

Here's the complete exported key from my system.
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Perl_program_file]
@="Perl program file"

[HKEY_CLASSES_ROOT\Perl_program_file\shell]

[HKEY_CLASSES_ROOT\Perl_program_file\shell\Execute Perl Program]

[HKEY_CLASSES_ROOT\Perl_program_file\shell\Execute Perl Program\command]
@="\"C:\\strawberry\\perl\\bin\\perl.exe\" \"%1\" %*"
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 39751484
After checking and possibly fixing the registry entry, see if you get the same output from this test.

c:\test>perl -e "print $_,$/ for @ARGV" 1 2 3
1
2
3
0
 

Author Comment

by:cpeters5
ID: 39752453
FishMonger,
No luck.  Attached is my regedit screen

Note: I just reinstalled version 5.18 in c:/perl64/.  No luck there either.

pax
regedit.pptx
0
 

Author Comment

by:cpeters5
ID: 39752626
Interestingly,
If I run my script with perl command.  I.e.
c:>perl myscript.pl 123 456
Then myscript.pl detected @ARGV = (123,456);

This suggests the problem is the file type association...

Here is the .PL assoc again

C:\>assoc .pl
.pl=Perl

with
$PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PL
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 39753956
Which distro did you install, Activestate or Strawberry, or some other one?

Your print screen shows that you still have the reg entry of the first perl installation.  Did you uninstall the old perl before installing the new version?

My guess is that the reg entries of the 2 installations are conflicting with each other.  Can you expand the other reg entry and post the print screen of it?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 28

Expert Comment

by:FishMonger
ID: 39753965
It also appears that you have PerlScript installed, which is Microsoft's implementation (port) of perl.  That could also be conflicting with your other installation.
0
 

Author Comment

by:cpeters5
ID: 39773315
FishMonger,
There were 3 versions installed.  I uninstall all three, all keys removed.  Then install fresh Perl 5.18.
After the installation, I activated ppm.  It detected only the 276 installed packages.  But this time, no error output as before.

Do you detect any problem in the attached screenshot for: regedit, ppm screen and Perl -v?

Also, do you have suggestion for a work around?  I have immediate need for a few modules such as DateTime, Location::GeoLoc, XML::Simple and some math::stuff

Thanks!
perlinfo.pptx
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 39773338
Everything looks good in your screenshot.

Are your scripts now able to see the command line args?  If so, then you should be fine and no "work around" would be needed.

Have you tried installing any of those modules?  If so, did they install properly or did they fail and produce error messages?
0
 
LVL 28

Accepted Solution

by:
FishMonger earned 500 total points
ID: 39773357
You'll want to add a few additional repositories to ppm.

Personally, I've moved away from using ppm and instead install all of my modules via cpan.  You first need to install MinGW-w64 to get the needed GCC compiler.

You might be able to install that via ppm.  At least it was available in the 32bit version.  I'm not sure if it's available in the 64bit version of ppm.
0
 

Author Closing Comment

by:cpeters5
ID: 39773748
Took me a while to find the right MinGW-w64 that works.
Thanks FishMonger.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

With the recent demise of Windows XP support, you may be a new convert to Windows 7 or Windows 8. Or perhaps you've been on W7 or W8 for a while, but just recently acquired your first scanner for the new OS. In either case, you are likely to be very…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now