Problems running perl without .pl extention

Discussion in 'Perl Misc' started by Kapil Khosla, Jun 19, 2004.

  1. Kapil Khosla

    Kapil Khosla Guest

    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
     
    Kapil Khosla, Jun 19, 2004
    #1
    1. Advertising

  2. Kapil Khosla

    ChrisO Guest

    Kapil Khosla wrote:
    > 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
     
    ChrisO, Jun 20, 2004
    #2
    1. Advertising

  3. Kapil Khosla

    ChrisO Guest

    Purl Gurl wrote:

    > 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
     
    ChrisO, Jun 20, 2004
    #3
  4. Kapil Khosla

    John Bokma Guest

    Purl Gurl wrote:

    > "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.

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


    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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 20, 2004
    #4
  5. Kapil Khosla

    John Bokma Guest

    ChrisO wrote:

    > 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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 20, 2004
    #5
  6. Kapil Khosla

    Kapil Khosla Guest

    "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


    Purl Gurl <> wrote in message news:<>...
    > Kapil Khosla wrote:
    >
    > (snipped)
    >
    > > 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 am highly skeptical.
    >
    > @ARGV provides only those arguments provided
    > to a Perl script. @ARGV does not contain
    > command line arguments which invoke your
    > perl core and specific perl file.
    >
    > "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.
    >
    > Your statements enjoy discrepancies.
    >
    >
    > > assoc .pl=Perl
    > > ftype Perl=perl.exe "%1" %*
    > > set PATHEXT=.pl;%PATHEXT%

    >
    > Research, read and learn about setting environment
    > variables for Win32 platforms, and learn about this
    > distinction between a GUI association and command
    > line parameters.
    >
    >
    > Purl Gurl
    > --
    >
    > #!perl
    >
    > print "Input Arguments: @ARGV";
    >
    > print "\n";
    >
    > print "Command Line Arguments: $ENV{CMDLINE}";
    >
    >
    > TEST RESULTS:
    > _____________
    >
    > C:\APACHE\USERS\TEST>perl test.pl
    > Input Arguments:
    > Command Line Arguments: perl test.pl
    >
    > C:\APACHE\USERS\TEST>perl test.pl one two three
    > Input Arguments: one two three
    > Command Line Arguments: perl test.pl one two three
     
    Kapil Khosla, Jun 20, 2004
    #6
  7. Kapil Khosla

    John Bokma Guest

    ChrisO wrote:

    > Purl Gurl wrote:
    >
    >> 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."


    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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 20, 2004
    #7
  8. Kapil Khosla

    John Bokma Guest

    Kapil Khosla wrote:

    > "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.



    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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 20, 2004
    #8
  9. Kapil Khosla

    Kapil Khosla Guest

    John Bokma <> wrote in message news:<40d50aff$0$25362$>...

    >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


    > Kapil Khosla wrote:
    >
    > > "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.

    >
    >
    > 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.
     
    Kapil Khosla, Jun 20, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carl Ogawa

    How do I make .cgi extention work?

    Carl Ogawa, Dec 27, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,017
  2. Howard

    change file extention

    Howard, Jan 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,043
    Teemu Keiski
    Jan 5, 2006
  3. shilpa
    Replies:
    3
    Views:
    8,873
    shilpa
    Jun 30, 2005
  4. Jesper Olsen

    C++ extention

    Jesper Olsen, Nov 18, 2003, in forum: Python
    Replies:
    2
    Views:
    460
    Jesper Olsen
    Nov 18, 2003
  5. elho
    Replies:
    0
    Views:
    252
Loading...

Share This Page