From: Ronald J Kimball <[EMAIL PROTECTED]>
   Date: Wed, 15 Jun 2005 14:05:28 -0400

   On Wed, Jun 15, 2005 at 12:38:21PM -0400, Mike T. Machenry wrote:

   > sub process { ... }
   > GetOptions ('<>' => \&process);
   > 
   > produces the following error:
   > 
   > Error in option spec: "CODE(0x80e4bbc)"
   > 
   > Does anyone know how I can pull out the non-option arguments without 
needing 
   > to have some named option present.

   It works for me . . .

   Getopt::Long version 2.34

   Ronald

Not quite; because Getoptions doesn't know how to parse --x, --bar, and
--foo, it gets the wrong tokens, and emits "Unknown option" warnings to
boot:

        [EMAIL PROTECTED]> ./opts.pl --x 5 --bar = 6 7 --foo 8 9
        Unknown option: x
        5
        Unknown option: bar
        =
        6
        7
        Unknown option: foo
        8
        9
        [EMAIL PROTECTED]> 

Instead, I would suggest doing a dummy parse:

        [EMAIL PROTECTED]> cat opts2.pl
        #!/usr/bin/perl -w

        use strict;

        use Getopt::Long;

        sub process { print "@_\n" }

        GetOptions ({}, 'x=i', 'foo=i', 'bar=i', '<>' => \&process);

        [EMAIL PROTECTED]> ./opts2.pl --x 5 --bar=6 7 --foo 8 9
        7
        9
        [EMAIL PROTECTED]> 

Saving @ARGV beforehand and restoring it afterward is left as an
exercise for the reader.  ;-}

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to