Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

The Monastery Gates

( [id://131] : superdoc . print w/replies, xml ) Need Help??

If you're new here please read PerlMonks FAQ
and Create a new user.

Quests
poll ideas quest 2024
Starts at: Jan 01, 2024 at 00:00
Ends at: Dec 31, 2024 at 23:59
Current Status: Active
1 reply by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Monk Quips Quest
Starts at: May 01, 2023 at 08:00
Ends at: Apr 30, 2024 at 07:59
Current Status: Active
9 replies by erzuuli
    Esteemed Monk kcott has recently proposed an excellent idea.

    heretoforthwithstanding, we invite all monks to submit ideas for new monk quips!

    Your quip suggestion should include the following details:

    • Intended quip location: either XP Nodelet, Chatterbox, or Monkbar (that's the page header).
    • Text of quip.
    • Optional: background & foreground colours. If you include these, be sure they are nicely contrasting.

    .

Perl News
CFP: Science Track Papers Needed at 2024 The Perl & Raku Conference
on Feb 26, 2024 at 06:01
0 replies by oodler
TPRC Call for Papers is open!
on Feb 16, 2024 at 20:39
1 reply by talexb

    The Call for Papers for The Perl and Raku Conference 2024 is now open!

    From the TPRF website, "TPRC 2024 is being held in Las Vegas, NV from June 24-28 2024." The organizing committe has a few surprises lined up -- there will be more information to come.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Supplications
Solved- Getopt::Long- Trying to specify "prefix" configuration option produces error
1 direct reply — Read more / Contribute
by parv
on Feb 24, 2024 at 18:24

    I was trying to set prefix option for Getopt::Long but that produces the error message as if that option is unknown or I am doing something wrong (what exactly?) ...

    use v5.32; use warnings; use Getopt::Long; printf qq[Version: perl %s, Getopt::Long %s\n], $^V, $Getopt::Long::VERSION; #use Getopt::Long qw[:config debug prefix - ]; # # Only difference is time, compile or run, of error ... # # Getopt::Long: unknown or erroneous config parameter "prefix" # Getopt::Long::Configure( q[debug], q[prefix], q[-] ); __END__ Version: perl v5.36.3, Getopt::Long 2.52 Getopt::Long: unknown or erroneous config parameter "prefix"

    ... So how do I set the prefix string?

    Got the same error with long_prefix_pattern configuration option. A search brings up issues with user options; did not see anything relevant to module configuration.

    Linked to here on Mastodon.

Enforce single hyphen for single character options in Getopt::Long
3 direct replies — Read more / Contribute
by mrnoname1000
on Feb 24, 2024 at 16:22

    Hiya, Perl newbie here! I've been learning it alongside Ruby with my background consisting of mostly shell, C, and Python (the latter of which takes a wholly different approach to argument parsing).

    As I write more Perl scripts with options, I prefer my option parser to be very strictly configured. My problem is that no matter how I configure Getopt::Long, it always accepts single character options with two preceding dashes. I achieved a compromise when rewriting one of my uglier sh+awk scripts, and here's a stripped down example:

    use Getopt::Long qw( :config posix_default gnu_compat bundling no_auto_abbrev no_ignore_case ); my $column = 1; GetOptions( 'column|c=i' => \$column, ) or die; die if $column < 1;

    I want this program to accept exactly two strings as options, --column and -c, but it also accepts --c. I want the prefix for short options to be - and only -, similar to how -- is treated for long options when bundling is enabled. I had hoped qw( :config prefix_pattern - long_prefix_pattern -- ) would get me what I want, but it seems like the latter isn't processed if the former doesn't match. Anyone know of a clean way to achieve this?

    Also, feel free to suggest improvements or mention best practices! If anyone wants, I can post the full script as well; it's intended to format numbers from stdin/files into human-readable sizes like 681.2K, 12.1M, 3.5G. I should probably figure out my preferred license as well...