Simon Strandgaard <neoneye / adslhome.dk> wrote in message news:<pan.2004.01.03.00.31.06.853624 / adslhome.dk>... > On Fri, 02 Jan 2004 15:25:04 -0800, GGarramuno wrote: > > > Simon Strandgaard <neoneye / adslhome.dk> wrote in message news:<pan.2004.01.02.19.24.35.766160 / adslhome.dk>... > >> > >> #begin /#end can tell the offset.. is that what you want ? > >> > > > > Kind of. Those are what I call the building blocks. > > > > The differences are that: > > a) That's an index that gets stored with the string variable, as if > > it were an attribute of it. > > b) It can also be set, like String#pos(number), so that any > > further matches or substitutions begin from that position on (this is > > somewhat akin to ruby's index()) > > How about #scan ? > No, different thing. > > > c) It interacts with the \G flag of regular expressions. > > never seen \G before.. is that global ? > From the perl manual... \G Match only at pos() (e.g. at the end-of-match position of prior m//g) Ruby supposedly supports it, but not as a setter, from what I can see so far (ie. it is missing pos()). > Agree on that, it looks obfuscated... but less than other perl modules I > have seen. Don't be fooled. It is one of the most obfuscated modules once you realize all it does with so little code. > > Anyway, here it is: > > http://www.cpan.org/modules/01modules.index.html > > Module is: Getopt-Declare. > > I am curios to how its differ from GetoptLong ? You can read the full docs at the end of the module (if you have perl, perldoc is better, thou). The docs are 1500 lines long. Overall, it is vastly superior and makes all other option parsing modules obsolete and primitive, imho. Among the not so standard features: - Allows also using a config file for options and reading parameters from other places other than commandline (files, for example). - It keeps the flags and docs as a single string (ie. you basically type the help string message ONLY and the module extracts the flags from that). It makes for extremely clean code while still allowing you to format the help line as you wish. Help line is provided automatically, too, removing special characters or blocks. - It supports arbitrary user created types for matching, not just string, numerics, etc. - For numbers it supports matching positive, negative w or w/o 0. - Allows arrays parsing and ranges parsing/expanding. - Allows matching parameters with a specific manual regex. - It supports all sorts of user shortcuts for flags (not just two). - Supports aliases for flags easily. - It creates regex code that can be spit out for matching if needed. - It allows code blocks to be imbedded (ie. when flags are seen full blocks can be parsed with perl, MUCH more powerful ways than other similar getopts) - Allows case to be ignored on a parameter or globally. - Allows options to be exclusive, inclusive, strict, etc. - Allows clustering of flags in a couple of forms - Allows parameters to be put on a queue, so that they only get interpreted after all others have. - Can check file parameter to verify their existance.