Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Parser for C/C++ application using Getopt::Declare and Convert::Binary::C

by roboticus (Chancellor)
on Feb 12, 2011 at 18:33 UTC ( [id://887785]=note: print w/replies, xml ) Need Help??


in reply to Parser for C/C++ application using Getopt::Declare and Convert::Binary::C

sg:

I'm afraid I don't get it. With your proposal, it appears to be a lot more hassle than required. Why would I want to use this instead of getopt()?

It seems that you need to keep your C program and your perl script in synch; you need to write your argument list twice (once to pass to perl, once to get it back), and you need to parse the data twice (again, once in perl and once in C). What are the selling points?

...roboticus

When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re: Parser for C/C++ application using Getopt::Declare and Convert::Binary::C
  • Download Code

Replies are listed 'Best First'.
Re^2: Parser for C/C++ application using Getopt::Declare and Convert::Binary::C
by sg (Pilgrim) on Feb 12, 2011 at 19:49 UTC
    True; the perl solution does involve some "double book-keeping work" and other inconveniences, and it might be preferable to keep the argument parsing entirely in C using getopt() or other libraries like http://argtable.sourceforge.net/ Argument parsing involves parsing, perl is a good tool for parsing, and so I wanted to see what a perl based solution might look like. And I am not sure getopt() supports the features supported by Getopt::Declare.

      sg:

      Perl definitely has some good parsing mojo, so I can understand that aspect of it. Perhaps it might make sense to make an Inline::C interface to your code? You could rename main(), and then do all your argument parsing and verification straight from perl. Then, if everything passes muster, you can call what would've been your main(), but with exactly predictable arguments (i.e., no further parsing required). That would reduce a little of the back & forth, and simplify keeping the perl in synch with the C, as the bits that would need to cooperate can be in the same module. That way, you'd get the parsing goodness of Getopt::Declare, and it might be a bit less work.

      Just a thought.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://887785]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-25 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found