Problems running perl without .pl extention

K

Kapil Khosla

Hi,
I have a small perl code
####
use strict;
print $#ARGV;
####

When I do perl 1.pl, it runs fine and gives the output 0.

But when I do 1.pl, it gives me the output -1.

I did the following already.

assoc .pl=Perl
ftype Perl=perl.exe "%1" %*
set PATHEXT=.pl;%PATHEXT%

This should have done the trick but it doesnt seem to work for me.
Anyone has any suggestions? I am testing this on Windows Server 2003.
Thanks a lot,
Kapil
 
C

ChrisO

Kapil said:
Hi,
I have a small perl code
####
use strict;
print $#ARGV;
####

When I do perl 1.pl, it runs fine and gives the output 0.

But when I do 1.pl, it gives me the output -1.

I did the following already.

assoc .pl=Perl
ftype Perl=perl.exe "%1" %*
set PATHEXT=.pl;%PATHEXT%

This should have done the trick but it doesnt seem to work for me.
Anyone has any suggestions? I am testing this on Windows Server 2003.

Your FTYPE command needs the full path to the command your are "F
typing"... Like:

c:\> ftype Perl=c:\perl\bin\perl.exe "%1" %*

That should do it, I would think.

-ceo
 
C

ChrisO

Purl said:
Research, read and learn about setting environment
variables for Win32 platforms, and learn about this
distinction between a GUI association and command
line parameters.

Translated means: "I'm not really sure what the answer to your problem
is, but I'd like to pretend that I do know, so I'll write this
condescending garbage as the 'answer' so I won't feel so stupid."

-ceo
 
J

John Bokma

Purl said:
"perl 1.pl"

That will result in -1 for $#ARGV.

"1.pl"

That will not run a perl script from a command line
based on your parameters.


C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>perl 1.pl
-1
C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>1.pl
-1
C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>type 1.pl
use strict;
print $#ARGV;

C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>
Your statements enjoy discrepancies.

With ActiveState it does.

After entering those 3, it still works for me:

C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>1.pl
-1

$#ARGV gives the highest index, which (normally) is number_of_items
minus one, so there are zero items in @ARGV, hence $#ARGV should report
-1. Why perl 1.pl shows something different, I don't understand.

(BTW, the assoc stuff should be set by ActiveState Perl at install time,
no need to do it manually)
Research, read and learn about setting environment
variables for Win32 platforms, and learn about this
distinction between a GUI association and command
line parameters.

Bla bla bla.

C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>assoc
..purl=Perl
..purl=Perl

C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>ftype
Purl=perl.exe "%1" %*
Purl=perl.exe "%1" %*

C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>set
PATHEXT=.purl;%PATHEXT%

C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>1.purl
-1
C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>type 1.purl
use strict;
print $#ARGV;

Maybe you should spend some time keeping stalkers and hackers using open
proxies from your website :-D. And stop them from abusing you and your
family.
 
J

John Bokma

ChrisO said:
Your FTYPE command needs the full path to the command your are "F
typing"... Like:

Not if the command is in the PATH.
c:\> ftype Perl=c:\perl\bin\perl.exe "%1" %*

That should do it, I would think.

The script was already running ok. Why perl 1.pl gave 0 is the problem :-D.
 
K

Kapil Khosla

"perl 1.pl"
That will result in -1 for $#ARGV.

You are right, but
perl 1.pl name1 RESULT = 0
1.pl name1 RESULT = -1

It seems that this is a common issue and is not related to enviroment
variables etc and I solved the problem by the following way.


To fix it I clicked:

Explorer -> Tools -> Folder Options -> File Types
Scrolled down to "PL - PL File"
Clicked "Restore"

It works as expected.
I have no idea why it wasn't working in the first place.
Thanks,
Kapil
 
J

John Bokma

ChrisO said:
Translated means: "I'm not really sure what the answer to your problem
is, but I'd like to pretend that I do know, so I'll write this
condescending garbage as the 'answer' so I won't feel so stupid."

She's just confused due to all those people trying to hack her server
looking for fat girls :p. I understood that their main device for
hacking is something called Yahoo! Picture Search. To make tracking a
bit more difficult they use Google too.
 
J

John Bokma

Kapil said:
"perl 1.pl"



You are right, but
perl 1.pl name1 RESULT = 0
1.pl name1 RESULT = -1

It seems that this is a common issue and is not related to enviroment
variables etc and I solved the problem by the following way.


C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>type 1.pl
use strict;
print $#ARGV;

C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>1.pl name1
0
C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>perl
1.pl name1
0
C:\Documents and Settings\John\Mis documentos\Projects\johnbokma>

So, I can not reproduce this using Win XP. I am sure it worked with
Windows2000, Win98, etc. So... Is this a 2003 issue?
To fix it I clicked:

Explorer -> Tools -> Folder Options -> File Types
Scrolled down to "PL - PL File"
Clicked "Restore"

It works as expected.
I have no idea why it wasn't working in the first place.

Me neither :-D.
 
K

Kapil Khosla

John Bokma said:
So, I can not reproduce this using Win XP. I am sure it worked with
Windows2000, Win98, etc. So... Is this a 2003 issue?

Yes. This looks like a Windows 2003 issue.
Thanks.
Kapil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top