Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Having problems with AppConfig::Getopt module

Expand Messages
  • Karl Kaufman
    FYI... I ve worked through my AppConfig/Getopt problems; here s the necessary fix. The latest release of the Getopt::Long (2.32) module is able to handle hash
    Message 1 of 1 , Aug 27, 2002
    • 0 Attachment
      FYI... I've worked through my AppConfig/Getopt problems; here's the necessary fix.

      The latest release of the Getopt::Long (2.32) module is able to handle hash arguments linked to code, but the current AppConfig module (1.52) hasn't yet been synced w/ the fix (so it still suffers from the problem, just in a different way).

      For now, here's my short-term workaround for the AppConfig::Getopt module to fix the problem (i.e. get it to play nice with the updated 2.32 Getopt::Long module). Edit the AppConfig::Getopt module (AppConfig/Getopt.pm), updating the $linkage variable, within the '_getopt_state' subroutine, to merge the extra hash value argument back into a 'key=value' pair.

      ### example fix for AppConfig::Getopt ###
      sub _getopt_state {
      ...<cut>...

      #my $linkage = sub { $self->set(@_) };
      my $linkage = sub {$_[1] .= "=" . pop() if ( $#_ eq 2 ) ;$self->set(@_)};
      ### example fix end ###

      Hope this helps.

      Karl

      p.s. Grab the new Getopt::Long module here:
      http://search.cpan.org/author/JV/Getopt-Long-2.32/

      ** p.p.s. The new AppConfig/Getopt::Long-2.32 symptom is that both the key and value are now passed to the linked subroutine by Getopt::Long as two different arguments, but AppConfig::State.pm expects them as a combined "key=value" argument -- so now the VALUE is lost. (Just the opposite of what happens when bound to Getopt::Long-2.19.) The AppConfig::Getopt fix above will merge the values back into a 'key=value' pair before shipping them off to AppConfig::State's set() method.

      ----- Original Message -----
      From: Karl Kaufman
      To: perl-beginner@yahoogroups.com
      Sent: Monday, August 26, 2002 11:54 PM
      Subject: Re: [PBML] Having problems with AppConfig::Getopt module -- need help bad


      Thanks for the advice; I'm heading that way now.

      Interestingly enough, the problem seems to be within Getopt::Long. A user 'arg' spec ('%') causes splitting of the value into $key and $arg... a problem if the variable is linked to 'CODE' -- as only the post-split $arg value is passed to the linked code.

      Regs,
      Karl K.

      ----- Original Message -----
      From: Nathan.Jeffrey@...
      To: perl-beginner@yahoogroups.com
      Sent: Monday, August 26, 2002 11:27 PM
      Subject: Re: [PBML] Having problems with AppConfig::Getopt module -- need help bad


      IMHO, you'd best be using Getopt::Long by itself. I've always found it
      suited my needs better than the extra-add-on bits, which never quite did
      what I wanted :-)

      N






      "karl_kaufman" <krkweb@...>
      27/08/2002 07:58 AM
      Please respond to perl-beginner


      To: perl-beginner@yahoogroups.com
      cc:
      Subject: Re: [PBML] Having problems with AppConfig::Getopt module -- need help bad



      My intent is to leverage AppConfig for merged command-line and
      configuration file handling. For a thorough discussion on why, see:

      http://www-106.ibm.com/developerworks/linux/library/l-perl3/

      The error may well push me back to "DIY", though.



      --- In perl-beginner@y..., "Prakash Kumar" <prakash@f...> wrote:
      > why dont u use @ARGV to get ur command line arguments ??




      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/







      _________________________________________________________________________________

      This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify Postmaster@...
      _________________________________________________________________________________


      Yahoo! Groups Sponsor
      ADVERTISEMENT



      Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.